Subject Finding a single row
Author Ertan Küçükoğlu
Hi,

I have a table where I keep some part from the beginning of a discount card
number. Length of beginning is variable. User provides a complete card
number at runtime, I need to find a single row in my table which begins as
the complete card number, or I need to know no match exists in my table.

I might do it coding in my application, but that would be way too slow
compared to an SQL statement I assume.

Table is as follows.
CREATE TABLE FIYATKODLARI(
Kodu Varchar(30) NOT NULL PRIMARY KEY
);

It contains something like:
Kodu
----
SA
SB
SSC
SAA
SBDE
8694
125

Complete card number may be something like:
SB1
SA25
SA325
SB1054
SAA23
86941005
12504

Below didn't work for me because complete card number is longer, and I do
lack SQL knowledge:
select * from FIYATKODLARI where Kodu like 'SB1%'

Any help is appreciated.

Thanks.
Ertan Küçükoğlu