Re: Help with SQL Syntax
Posted in 1996
Harold Sasaki (hsasaki@shellx.best.com) wrote: : I'm trying to query a table, but my syntax is not working. Here's : what I'm trying to do: Select all fields where a serial is a certain : number and a field does not match a certain string. : select * from table where serial = "1" and status not matches "killed" ^^^^^ ^^^^^^ ^ ^ ^^^^^^ ^^^^^^^^ Harold, I hope that the table and column names in your example query are only placeholders. "table","serial" and "status" are reserved words and must not be used as table, column or variable names to avoid problems. But I assume you knew that... There are two anomalies in your example that strike me: 1) A serial column is defined as an integer, so you should omit the quotes around it. Shouldn't make a difference due to implicit type conversion, but who knows? Your actual query might be different. 2) Using the "matches"-operator doesn't make any sense without wildcards. If you actually are looking for "killed", then "!=" must work. If you are looking for something like "process killed due to stack overflow" or "killed in car accident", then you must use "*killed*" together with the "matches" operator. Keep in mind that Informix-SQL doesn't allow for case-insensitive searches, so if "killed" isn't all lowercase in your column, the above cannot yield the result you wanted. Hope this helps, Richard -- +----------------------------+-------------------------------------------+ | Dr. Richard Spitz | INTERNET: spitz@ana.med.uni-muenchen.de | | EDV-Gruppe Anaesthesie | Tel : +49-89-7095-3421 | | Klinikum Grosshadern | FAX : +49-89-7095-8886 | | 81366 Munich, Germany | | +----------------------------+-------------------------------------------+