motioneye
asked on
sql query
Hi,
How do I query a single table with two column in where clause for a multiple values ? I have a value with me in where cluse but not sure how to put this in construct query
The where clause must be a combination of two column within a table , the query below works with only per row ouput, but how I have this for multiple value ?
select * from VemployeeDisc where [AD Domain] ='AAPAC' and [ADACCTName]='EMMKZY'
[AD Domain] [ADACCTName]
AAPAC EMMKZY
AMERICAS EMMZZZ
AAPACII EMMZARO
How do I query a single table with two column in where clause for a multiple values ? I have a value with me in where cluse but not sure how to put this in construct query
The where clause must be a combination of two column within a table , the query below works with only per row ouput, but how I have this for multiple value ?
select * from VemployeeDisc where [AD Domain] ='AAPAC' and [ADACCTName]='EMMKZY'
[AD Domain] [ADACCTName]
AAPAC EMMKZY
AMERICAS EMMZZZ
AAPACII EMMZARO
AND Return value if both AD Domain and ADACCTName satisfy,
If you want to return any of them you can use OR,IN,Between functions as per Ryan Chong solution.
If you want to return any of them you can use OR,IN,Between functions as per Ryan Chong solution.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi,
Actually in the table it self we have multiple values as below and the problems is I need to select maybe around 20-30 records for an ad-hoc request from user
[AD Domain] [ADACCTName]
AAPAC EMMKZY
AMERICAS EMMZZZ
AAPACII EMMZARO
AAPACII EMMZZZ
AMERICAS EMMKZY
AAPACII EMMZARO
Actually in the table it self we have multiple values as below and the problems is I need to select maybe around 20-30 records for an ad-hoc request from user
[AD Domain] [ADACCTName]
AAPAC EMMKZY
AMERICAS EMMZZZ
AAPACII EMMZARO
AAPACII EMMZZZ
AMERICAS EMMKZY
AAPACII EMMZARO
if you are comparing similar values in a field, you probably can use Like clause instead.
for example:
select * from VemployeeDisc where [AD Domain] like '%AAPAC%' OR [ADACCTName] like '%EMM%'
for more info:
https://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html#operator_like
for example:
select * from VemployeeDisc where [AD Domain] like '%AAPAC%' OR [ADACCTName] like '%EMM%'
for more info:
https://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html#operator_like
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
motioneye, do you still need help with this question?
select * from VemployeeDisc where [AD Domain] ='AAPAC' OR [ADACCTName]='EMMKZY'
or:
select * from VemployeeDisc where [AD Domain] in ('AAPAC','EMMKZY') OR [ADACCTName] in ('AAPAC','EMMKZY')
?