Jump to content

Domain status sql query


chrismfz

Recommended Posts

Hello, can someone with better SQL knowledge than me help me ? :-P

 

We can recall .gr domains as registrars and we have a "grace" period

of 5 days. So we are automatically register for the client the .gr domain

he wants and we recalling it with an Addon Module we created.

 

So we can just enter the domain name (in a textbox) and click the recall

button. Domain is recalled and we have 5 more days till the client pays and

so on...

 

Now, because after of a number of orders we get confused, I want to do

a SQL query in the same Addon Module to show me which domains

have Status = Unpaid in the invoices. So I will get the list only

with domains which we didnt get paid yet.

 

First I tried this one when I was playing around:

$query = "SELECT domain,status from tbldomains WHERE registrar = 'eppgr';";

which gives me ALL .gr domains... But I need only them which is unpaid.

 

So I also tried this:

 

$query = "SELECT tbldomains.domain
from tbldomains
INNER JOIN tblinvoices
ON tbldomains.userid=tblinvoices.userid
WHERE tbldomains.registrar = 'eppgr' AND tblinvoices.status='Unpaid';";

and this:

 

$query = "select tbldomains.domain from tbldomains INNER JOIN tblinvoices ON
tbldomains.userid=tblinvoices.userid WHERE tbldomains.registrar = 'eppgr' AND tblinvoices.status='Unpaid'";

But I get again ALL domains back not unpaid...

What's wrong ? What I did wrong / mistake ?

 

I only need the domains which in their invoice are marked as unpaid... So we can keep recalling

them until we mark their invoiced paid...

 

Anyone ?

Link to comment
Share on other sites

SELECT  * 
FROM tblinvoices
WHERE  STATUS  =  "Unpaid"
AND id
IN (
SELECT invoiceid
FROM tblinvoiceitems
WHERE  TYPE  =  "Domain"
AND description LIKE  "%gr%"
)

 

Thanks a lot! It work about ...50% :-P

 

I get the Ids of the invoices which any *gr domain is Unpaid.

 

But how can I get the domain name too ?

 

I tried similar sql code and editing this one but I got either errors or no output at all :roll:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated