ninedoors Posted April 9, 2008 Share Posted April 9, 2008 Is there anything wrong with this query? I have two tables one named 'currentlocations' and the other named 'frcstqunt'. They both have a column named sku. Is this the correct way to select only the sku's from currentlocations that are also in frcstqunt? <?php //get matching skus from currentlocations $query = "SELECT currentlocations.sku FROM currentlocations WHERE currentlocations.sku = frcstqunt.sku"; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { $arraycurrsku[] = $row['sku']; } ?> I have checked the sku's in each table manually and there are exact matching skus that exist in both but I am return an empty array. I would like to collect them all in an array for use. Any thoughts? Link to comment https://forums.phpfreaks.com/topic/100316-select-intersect-problem/ Share on other sites More sharing options...
soycharliente Posted April 9, 2008 Share Posted April 9, 2008 Does this work better? $query = "SELECT sku FROM currentlocations c JOIN frcstqunt f ON c.sku=f.sku"; Link to comment https://forums.phpfreaks.com/topic/100316-select-intersect-problem/#findComment-512968 Share on other sites More sharing options...
ninedoors Posted April 9, 2008 Author Share Posted April 9, 2008 Nope. I get this error: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\PTL\skudiff.php on line 49 Link to comment https://forums.phpfreaks.com/topic/100316-select-intersect-problem/#findComment-512976 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.