> I am trying to make a SELECT command like this:
> $qid =db_query("
> SELECT ID, NAME, ADDRESS
> FROM users
> WHERE ID=* AND NAME='John'
> Is it somehow possible to have a wildcard, so it returns all
> records, where
> the name is john and the ID is not important?
Well for a query like that just omit ID=
$qid = db_query("SELECT ID, NAME, ADDRESS FROM users WHERE Name = 'John'");
It will still find all the records you want and only uses Name as the
However yes it is possible to use wildcards...MOST databases support it but
you'll need to check with your db distributor to know for sure. Typically
the wildcard is % (an equivalent to * as a wild card)...some DBs also
support ? as a one character wild card...however to use them you have to use
the LIKE function.
So say if you wanted to find queries WHERE the name started with an A
$qid = db_query("SELECT ID, NAME, ADDRESS FROM users WHERE Name LIKE 'A%'");
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php