![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Apr 2008
Posts: 43
Rep Power: 0
![]() |
Hello
How do you querry and find records where specific characters are present in the string in a specific column. I did not find a better place to post this question so here it is: I have a column (FirstColumn) in my table with string values such as: D2-L4-X1 D3-L4-X4 D9-L8-X9 SELECT * FROM tblListing WHERE FirstColumn = 'L4' would not work. I tried LIKE that did not work either. How would you do this querry? Thanks a million in advance.
__________________
^c^ |
|
|
|
|
|
#2 |
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 498
Rep Power: 4
![]() |
Re: Sql Select
Did you try this: here
WHERE substring(FirstColumn,0,2) = 'L4' or this depending on the implenmentation of SQL WHERE substr(FirstColumn,0,2) = 'L4'
__________________
I Like Ike. Vote for Dwight Eisenhower this November. --This message brought to you by the the Procrastinators Club Of America. |
|
|
|
|
|
#3 |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 747
Rep Power: 3
![]() |
Re: Sql Select
did you try something like
SELECT * FROM tlbListing WHERE FirstColumn LIKE '%F4%'?
__________________
<insert disclaimer here> <insert shameless plug for Visual Studio here> |
|
|
|
|
|
#4 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Re: Sql Select
Wouldn't you be better off here with two tables? tblListing can link to another table which contains the same ID and multiple FirstColumns.
tblListing: ID | RandomColumn | OtherColumn ---+--------------+------------ 1 | 46 | 910 2 | 9295 | 11 3 | 7 | 125 tblFirstColumn: ID | FirstColumnPart ---+---------------- 1 | D2 1 | L4 1 | X1 2 | D3 2 | L4 2 | X4 3 | D9 3 | L8 3 | X9 Then you can do this: SELECT tblListing.* FROM tblListing, tblFirstColumn WHERE tblListing.ID = tblFirstColumn.ID AND tblFirstColumn.FirstColumnPart = 'L4' |
|
|
|
|
|
#5 |
|
Programmer
Join Date: Apr 2008
Posts: 43
Rep Power: 0
![]() |
Thank you guys
Thank you guys I tried all your suggestions and each one worked.
Coffee shuld be on me!
__________________
^c^ |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Select Non distinct in MySQL | davil | PHP | 12 | Dec 6th, 2007 5:48 AM |
| SQL: Rewrite a complex join without #temp tables? | jonyzz | Other Scripting Languages | 1 | Sep 5th, 2007 10:51 AM |
| Detach an in-use database via code (SQL Server 2000) | sma_soft | C# | 1 | Aug 14th, 2007 2:22 PM |
| reloading html select boxs...is there a better way? | MegaArcon | Python | 13 | May 26th, 2006 3:06 AM |
| sockets, problem with select() | Wizard1988 | C++ | 0 | Jan 15th, 2006 4:09 PM |