Table A has userIdentity (primaryKey) userName userPhoneNumber
Table B has someOtherKey(primaryKey) userIdentity userLocation
I get 22 rows with unique userIdentity when I run
SELECT *
FROM tableB
WHERE tableB.timeStamp > '2013-11-1'
GROUP BY tableB.userIdentity ;
I get only 2 rows when I run (I intend to extract name and phone number of the 22 rows in the above query)
SELECT tableA.userName, tableA.phonePhoneNumber
FROM tableB
JOIN tableA
WHERE tableB.timeStamp > '2013-11-1'
GROUP BY tableB.userIdentity
AND tableA.identityHash = tableB.identityHash;
I'm pretty sure your 'AND' clause is in the wrong place. What you probably meant to do was:
SELECT tableA.userName, tableA.phonePhoneNumber
FROM tableB JOIN tableA
WHERE tableB.timeStamp > '2013-11-1'
AND tableA.identityHash = tableB.identityHash
GROUP BY tableB.userIdentity;
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments