Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Urgent !!!!

Author  Topic 

meenu_susi
Starting Member

1 Post

Posted - 2010-12-08 : 12:13:45
Hi guys I have created a form in PHP which has 3 listbox options,
name, city and country, now if a employee selects a value in
any one of the listbox and clicks search, then the related record should be pulled out from a table (all records are stored ina single table)

for eg : if I select 2 options name and city the relates records should be filtered and displayed

same way when i select all the 3 options and then the relates records should be displayed

And I am not having any submit button everything should happen on the click event....

Since I am new to SQL Query can anyone help me to create the SQL Query

May me you can send me soem sample Query

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-12-08 : 12:43:19
You've posted your question on a Microsoft SQL Server site. You'd be better off posting your question on a site that specializes in php, and since you are most likely using MySql you could try a MySql site too.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-12-20 : 08:39:04
This is the general logic

where (col1=@param1 or @param1 is null) and (col2=@param1 or @param2 is null) and (col3=@param3 or @param1 is null)

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-12-20 : 13:09:39
Except that this can cause you performance problems. Catch all queries are expensive when done that way.

Gail wrote a good article:
http://sqlinthewild.co.za/index.php/2009/03/19/catch-all-queries/

Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-12-20 : 13:46:07
DECLARE @p1 table(p varchar(20)); INSERT INTO @p1(p) SELECT @parameter1
DECLARE @p2 table(p varchar(20)); INSERT INTO @p2(p) SELECT @parameter2
DECLARE @p3 table(p varchar(20)); INSERT INTO @p3(p) SELECT @parameter3

SELECT * FROM myTable99 t
LEFT JOIN @p1 p1 ON p1.p = t.p1
LEFT JOIN @p2 p2 ON p2.p = t.p2
LEFT JOIN @p3 p3 ON p3.p = t.p3



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -