Jump to content

Mysql query to pull client data for hosting orders


Recommended Posts

Hello. I'm trying to create a mysql query to pull some data for a powershell script I'm working on. It works great UNTIL a client orders a 2nd product. Then the tblclients table no longer has the same amount of records as the tblorders and tblhosting tables. This is an issue since I joined the tblhosting and tblclients tables using 'id'. The tblorders and tblhosting tables have 'userid' but unfortunately it isn't in tblclients. The tblclients table has 'uuid' but I don't see any tables that tie the 'uuid' to 'userid'. Does anyone know how I could accomplish pulling in the correct client data for an order? This is the query I have so far. Thanks in advance for any assistance you can provide.

 

select tblorders.userid, tblorders.id, tblhosting.domain, tblorders.status, tblclients.email, tblclients.companyname, tblcustomfieldsvalues.value

from tblorders

LEFT JOIN tblhosting ON tblorders.userid=tblhosting.userid

LEFT JOIN tblclients ON tblhosting.id=tblclients.id

LEFT JOIN tblcustomfieldsvalues ON tblorders.id=tblcustomfieldsvalues.relid

where tblorders.status = 'Pending' group by tblorders.status;"

 

 

Thanks,

 

Kelvin

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