For smart Primates & ROBOTS (oh and ALIENS ).

Blogroll

Friday, September 19, 2014

SQL query for two column from and to with same value

SQL query for two column from and to with same value

Suppose you are developing a software, you have a database table with following structure:
zip_id from_zip1 from_zip2 ship_cost
1         0         100         40
2         101         200         50
3         201         350         100

In the data entry screen you put the Zip code as 315. Zip code 315 coming under zip id 3 and it's shipping cost is 100.
you want when user put zip 315 or any other zip then it's according shop cost automatically show.
So what will the sql query of this?

This will the query of that:

SELECT *FROM ship
WHERE (from_zip2>=315 AND from_zip1<=315)
ORDER BY from_zip2 DESC LIMIT 0, 1


Share:

0 comments:

Post a Comment

Multiple attribute passing in querySelectorAll

Multiple attribute passing in querySelectorAll     Here I am demonstrating code to how to pass multiple attributes in querySelectorAll. <...

Ads Inside Post

Powered by Blogger.

Arsip

Blog Archive