Page 1 of 1

please tell me why use "select IF"

Posted: Wed Nov 28, 2007 12:56 am
by yanglei1979
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Code: Select all

$query = mysql_query("select IF(c.customers_payment_allowed <> '', c.customers_payment_allowed, cg.group_payment_allowed) as payment_allowed from " . TABLE_CUSTOMERS . " c, " . TABLE_CUSTOMERS_GROUPS . " cg where c.customers_id = '" . $customer_id . "' and cg.customers_group_id =  '" . $customer_group_id . "'");

please tell me why use: "select IF"?

what is the mean to use "select IF" in mysql query?

and the string : "customers_payment_allowed <> '' ",

i don't know why use this string.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Choose the Right Board

Posted: Wed Nov 28, 2007 1:18 am
by s.dot
IF() is an if/else construct.

The `something` <> '', is the same thing as `something` != '', so <> is the not equal operator

http://dev.mysql.com/doc/refman/5.0/en/ ... y-ref.html

Moved to databases
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:1. Select the correct board for your query. Take some time to read the guidelines in the sticky topic.