Home > Blockchain >  SQL - Query to find records that contain part of the value
SQL - Query to find records that contain part of the value

Time:03-16

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

CodePudding user response:

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

  • Related