How To Find A Match From Specific Values In MySQL
Computing : Learning PHP With mySQL a common need is to take out data from the database where various criteria are in place. Thus the use of the WHERE keyword to restrict the returned data, as opposed to a SELECT that is not qualified by a WHERE. You may have a few possibilities to the WHERE though and this can get confusing with OR. For instance if you want to get the rows where the id is 10,20,30,40 you might do: SELECT * FROM mytable WHERE id = 10 OR id = 20 OR id = 30 OR id = 40 You quickly get confused and it can make a long query unwieldy. Therefore use the keyword IN which makes it clearer and easier to construct such a query, particularly with a large list of values: SELECT * FROM mytable WHERE id IN (10,20,30,40)
Questions about PHP and mySQL:
|
|