-3

I have table zipcode which has a column called code. The Code column contains the prefix of zipcodes like

395
453
302
1203
12

I want to write an SQL query that checks if the provided zipcode matches one of the values in the table. (Something like isValid)

I want to avoid writing all zip codes in the database.

Valid Input zipcode

395004
395152
3952
1256

Can anyone help me? Thanks

Pramod Tapaniya
  • 1,228
  • 11
  • 30

1 Answers1

1

simple sql query:

select * 
from zipcode 
where '395004' LIKE CONCAT(code,'%'); 

references: SQL - Query to find if a string contains part of the value in Column

VBoka
  • 8,995
  • 3
  • 16
  • 24