Making Multiple Distinc or Unique (No Duplicates) Queries In MySQL
- Forums
- MySQL
- Making Multiple Distinc or Unique (No Duplicates) Queries In MySQL
if you are wondering how you can do a query with multiple not like in your msyql php scripts, i will show you my mistake and maybe you can learn from it. [927], Last Updated: Sat May 18, 2024
wallpaperama
Sun Feb 27, 2011
0 Comments
1019 Visits
i am doing this query for a table and i dont want to include the rows which contain certain words,
if you are wondering how you can do a query with multiple not like in your msyql php scripts, i will show you my mistake and maybe you can learn from it.
this is how i had my query:
INCORRECT WAY:
$query = "SELECT * my_table WHERE lastname NOT LIKE '%doe%' OR NOT LIKE '%john%'";
but this is how it should have been:
CORRECT WAY:
$query = "SELECT * users WHERE lastname NOT LIKE '%smith%' OR lastname NOT LIKE '%johnson%'";
the above query does a search but it ignores the people in my users table with the last names as smith or johnson
you see the mistake i made?