Page 1 of 1
select problem
Posted: Sat Apr 17, 2004 6:35 pm
by potato
Hi,
i am wondering how i can select where the word start with the letter a for example?
Posted: Sat Apr 17, 2004 6:40 pm
by tim
as in results from a MySQL table?
Make use of the % sign, its a wildcard like * is.
=]
SELECT field_name FROM table_name WHERE field_name LIKE 'a%';
Posted: Sat Apr 17, 2004 6:45 pm
by potato
thanx
Posted: Sat Apr 17, 2004 6:46 pm
by tim
very welcome.

Posted: Sat Apr 17, 2004 6:57 pm
by potato
this is my query:
mysql_select_db($database_memberships, $memberships);
$query_Recordset1 = sprintf("SELECT * FROM users WHERE username like '%m%'");
$Recordset1 = mysql_query($query_Recordset1, $memberships) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1); ?>
and this i get as result:
Warning: sprintf(): Too few arguments in /home/httpd/vhosts/bevibed.be/httpdocs/TMPmw0dswcaeq.php on line 5
Query was empty
What did i wrong?
Posted: Sat Apr 17, 2004 7:05 pm
by feyd
sprintf requires more than one argument because you passed it a special character % without escaping it. It appears that you want to set $query_Recordset1 to that string..
Code: Select all
$query_Recordset1 = "SELECT * FROM users WHERE username like '%m%'";