Reputation: 11
Cust_Id Name Phone -------------------------- A001 John 88888 A002 Smith 77777 A003 Stella 66666
Currently I'm executing 3 queries like: SELECT Name, Phone from tablename WHERE Cust_Id = 'A001'. and similarly for A002 & A003 The above query would return : $row[Name], $row[Phone].
Is there any way in which I can run a single query and get the results as: $row[A001][Phone] or I could reference the values directly.
The table has more than 3 tuples.
Any help would be appreciated.
Upvotes: 1
Views: 91
Reputation: 263803
why not use IN
SELECT Name, Phone
FROM tablename
WHERE Cust_Id IN ('A001','A002', 'A003')
and which is the same with
SELECT Name, Phone
FROM tablename
WHERE Cust_Id = 'A001' OR
Cust_ID = 'A002' OR
Cust_ID = 'A003'
Upvotes: 1