Click here to Skip to main content
15,910,872 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
if a table have these columns ::

Column ID:: Column Name ::: Column desc ::: column a :: Column b

and if the query is select * from table where columnid like '0';

its return data related to columnid 0 only

and can we do this :: select * from table where columnid like '0','1','2'; ?
Posted

SQL
ColumnID IN ('0','1','2') 
 
Share this answer
 
Hi,

If you're only looking for the record that has the columnid value of 0, then this is better:
SQL
select * from table where columnid = '0';


You can't really do:
SQL
select * from table where columnid like '0','1','2';


If you are trying to retrieve records that have a columnid value of 0 1 or 2, then this would work:
SQL
select * from table where columnid IN ('0','1','2');

... and if columnid is defined as an integer data type, then you would be better with:
SQL
select * from table where columnid IN (0,1,2);


Hope it helps.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900