Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql n00b question.. query construction

Status
Not open for further replies.

br0ck

MIS
Apr 25, 2002
467
US
sql n00b question.. query construction

I have a helpdesk system that I can search for tickets. There are many drop down selection boxes that I can use to define the search. However I need to do some custom searches.

There is a line that I can enter a sql statement.

There is one table called Task status that has: open, closed, pending, etc..

I want to be able to search all tickets that are not equal to Closed for example

Or not equal to “closed” and “open”

Can some one help me

Code:
SELECT * from hds_tickets where__________________________

Thank you

 
Hi

Theoretically...
Code:
[b]select[/b] * [b]from[/b] hds_tickets [b]where[/b] status!=[i]'closed'[/i];

[gray]-- or[/gray]

[b]select[/b] * [b]from[/b] hds_tickets [b]where[/b] status!=[i]'closed'[/i] [b]and[/b] status!=[i]'open'[/i];
Your question was not too clear. Could you post the table structure ?

Feherke.
 
... thakns for the fast responce.

i entered your line:
Code:
select * from hds_tickets where status!='closed' and status!='open';
and got this:
Code:
Invalid query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\'closed\' and status!=\'open\'' at line 1

as for posting the table structure> how can i do that is there a command tha ti can enter to dump that info
(this Helpdesk is a PHP/MYSQL package so i didnt have to bild the tables)


sorry for my lack of knowledge!

 
Hi

br0ck said:
[red]\[/red]'closed[red]\[/red]' and status!=[red]\[/red]'open[red]\[/red]'
Looks bad. PHP has the [tt]magic_quotes_gpc[/tt] option turned on in your php.ini file. That will avoid sending plain single quotes ( ' ) from the browser. Your only option is to turn it off. But then stupid scripts, like the one you use, may crash or mess up the database.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top