danjen
asked on
MYSQL Update Query with INNER JOIN returning 0 rows
Hi Experts -
The following query is updating 0 rows, but if I do a select statement with the same join and where i get 23 records. Can you tell me what i am typing wrong?
¿¿¿¿¿¿update Price inner join popular on popular.SKU = Price.SKU set Price.Featured = 3 where Price.Featured <> 2;
Thanks for the help.
The following query is updating 0 rows, but if I do a select statement with the same join and where i get 23 records. Can you tell me what i am typing wrong?
¿¿¿¿¿¿update Price inner join popular on popular.SKU = Price.SKU set Price.Featured = 3 where Price.Featured <> 2;
Thanks for the help.
ASKER
Well that helped narrow it down a little bit:
select *
FROM
Price
INNER JOIN popular ON popular.SKU = Price.SKU
This query returns 23 rows
If I do this I get 0 rows;
select *
FROM
Price
INNER JOIN popular ON popular.SKU = Price.SKU where Price.Featured <> 2
There are 5000 records in the Price file and only 15 have the value 2 in the Featured column. So the other 4000 should be listed.
Thanks for the help.
select *
FROM
Price
INNER JOIN popular ON popular.SKU = Price.SKU
This query returns 23 rows
If I do this I get 0 rows;
select *
FROM
Price
INNER JOIN popular ON popular.SKU = Price.SKU where Price.Featured <> 2
There are 5000 records in the Price file and only 15 have the value 2 in the Featured column. So the other 4000 should be listed.
Thanks for the help.
>So the other 4000 should be listed.
only if they have a matching record in the popular table (based on the SKU value) !
only if they have a matching record in the popular table (based on the SKU value) !
and your first query, returning "only" 23 rows, shows that most records in price do NOT have the SKU in popular table.
ASKER
i figured out a solution but maybe you can explain:
when I leave off the where I noticed that column Featured contained all NULL records which are not equal to 2 so they should have been listed. If I change the where to "Where Featured is null" the update worked.
Any ideas
when I leave off the where I noticed that column Featured contained all NULL records which are not equal to 2 so they should have been listed. If I change the where to "Where Featured is null" the update worked.
Any ideas
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
except that you change "something" essential in the query, the update should be ok...