Select from where field not equal to Mysql Php -


I'm wondering what kind of mysql command can be executed in PHP, which can be used by all items Where columna is not equal to x and x is equal to x

is not something like this: Choose something from the table where the columna x is not equal to and not equal to the column x

Any thoughts?

The key is the SQL query, which you will set as the string:

  $ sqlquery = "select Field 1, the table from field 2 where the column is not = 'x' and not columbB = 'y'";  

Note that there are several ways to not specify I another that works the same way:

  $ sqlquery = "select Field 1, From table 2 to table where column A = 'X' and columbB! = 'Y' ";  

Here is a full example of using it:

  $ link = mysql_connect ($ dbHost, $ dbUser, $ dbPass) or die ("database Unable to connect to "); Mysql_select_db ("$ dbName") or die ("Unable to select database $ dbName"); $ Sqlquery = "select Field 1, the table from field 2 where the column is not = 'x' and not columbB = 'y'"; $ Result = mysql_query ($ sqlquery); While ($ line = mysql_fetch_assoc ($ result) {// do stuff}  

You can do whatever you like on top of the loop. Access each field in the table as an element $ line array means that $ line ['field1'] will give value to field1 in the current row, and $ Line ['field2'] will give value to you for field2 .

Note that if the NULL Believe it, any of them above You will add the clause to include the NULL values:

  $ sqlquery = "SELECT field1", where the table from field 2 (column Is not = 'x' or column is a null) and (not columbB = 'y' or column b is null) ";  

Comments