Jump to content

Advanced SQL syntax


Kian

Recommended Posts

Hi

 

Let's talk about SQL syntax. We have this query...

 

	$table_hosting = "tblhosting";
$fields_hosting = "packageid,server";
$where_hosting = array("userid"=>$return_orders['userid'],"domainstatus"=>"Active");
$result_hosting = select_query($table_hosting,$fields_hosting,$where_hosting);
$return_hosting = mysql_fetch_array($result_hosting);

 

What if i'd want to add an OR operator in the WHERE statement? To make it more clear i translate it with a standard MySQL syntax...

 

SELECT packageid, server FROM tblhosting 
WHERE userid=$return_orders['userid'] AND domainstatus="Active" OR paymentmethod="paypal"

 

(?) This is my 1st question

 

Now let's go on with a more "complicated" query. What if i'd want to add the OR/AND in a "IN"? Here's the example with the standard MySQL syntax...

 

SELECT packageid, server FROM tblhosting 
WHERE $return_orders['userid'] IN (userid) AND domainstatus="Active" OR domainstatus="Suspended"

 

(?) This is my 2nd question

 

I hope that someone can explain me because i'm tired to filter queries with php instead of make them ready-to-use and of mixing WHMCS-SQL syntax with MySQL one in the same code.

Edited by Kian
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