Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 column search

Author  Topic 

shamsherule
Starting Member

4 Posts

Posted - 2011-12-16 : 05:56:41
hi all ;
i have a table called car_detail it contain columns: code ,details ,model,price etc.in details column it stores manufacturing year and other details ,my question is how to select a row from table with code and year of manufaturing ;Thanks in advance;

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2011-12-16 : 05:59:45
Can you provide sample data from the "details" column?

Senthil Kumar C
------------------------------------------------------
MCITP - Database Administration SQL SERVER 2008
MCTS - Database Development SQL SERVER 2008
Go to Top of Page

shamsherule
Starting Member

4 Posts

Posted - 2011-12-16 : 06:05:58
quote:
Originally posted by senthil_nagore

Can you provide sample data from the "details" column?

Senthil Kumar C
------------------------------------------------------
MCITP - Database Administration SQL SERVER 2008
MCTS - Database Development SQL SERVER 2008



2005 red honda;
Go to Top of Page

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2011-12-16 : 06:11:48
Select * from table_name where left(details,4)=2005 and code ='xxx'

Assumption "details" always have year on first 4 character
Senthil Kumar C
------------------------------------------------------
MCITP - Database Administration SQL SERVER 2008
MCTS - Database Development SQL SERVER 2008
Go to Top of Page

shamsherule
Starting Member

4 Posts

Posted - 2011-12-16 : 06:15:35
quote:
Originally posted by senthil_nagore

Select * from table_name where left(details,4)=2005 and code ='xxx'

Assumption "details" always have year on first 4 character
Senthil Kumar C
------------------------------------------------------
MCITP - Database Administration SQL SERVER 2008
MCTS - Database Development SQL SERVER 2008


Thank you Senthil Kumar !..
how can we search if the year is middle of in details column;
Go to Top of Page
   

- Advertisement -