Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 7th, 2004, 04:08 PM
Authorized User
 
Join Date: Nov 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default Query for two conditions needed

I want to extract data from the database with two conditions on it.

What is the query if i want two where clause in a query.

Means i want to extract the data from the garments table. Means i want to get the data where garments belongs to men and garment type is T-shirts. What will be the query for this?

Is there involved AND? Kindly plz help!

Farzan Q.
BS(TeleCommunication)
Iqra University.
__________________
Farzan Q.
MS(TeleCommunication)
Mohammad Ali Jinnah University.
 
Old November 7th, 2004, 04:27 PM
Authorized User
 
Join Date: Nov 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I got the query. I m posting here..may be it could help someone in future.

sql = "SELECT * FROM Garments WHERE Garment_Who Like '"&garment_who&"'AND Garment_Type Like'"&garment_type&"'"


***Garment_Type and Garment_Who are the fields in database.

Farzan Q.
BS(TeleCommunication)
Iqra University.
 
Old November 9th, 2004, 06:24 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

LIKE operator is used for pattern search. if you are sure that you check for the exact phrase, you can better use = operator. When you use LIKE operator use % before and/or after the phrase.
Code:
sql =  "SELECT * FROM Garments WHERE Garment_Who Like '%"&garment_who&"%'AND Garment_Type Like'%"&garment_type&"%'"
Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
Quotes in query; help needed! Hylmar MySQL 3 December 21st, 2006 11:37 PM
Help needed with JOIN Query icecrew SQL Server 2000 3 October 16th, 2006 11:59 AM
Nested Query Help Needed Corey Access 2 April 26th, 2006 02:17 PM
Seemingly Complicated Query help needed krashed SQL Language 5 March 31st, 2006 01:02 AM
Help needed with calculation in a query Lovegroover Access 6 August 18th, 2005 10:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.