PDA

View Full Version : querying a keyword thats start the first Letter


che_anj
02-12-2008, 03:24 PM
hello could anyone know how to query an entry at one field thats start with the first letter that I choose.

example..
I have a table having a fields of (candidatename,keywords)

the entry of a keyword is compose of many words like C Programming, C++, novell, mysql, php, linux, windows.

now, Id like to display a keyword that starts with the letter C..

my query goes like thise..

$sql="select * from table where keywords like 'C%' or keywords like 'php%' ";

but this query result zero .. can anyone knows how to have a query on this..

thanks..

Andrew Johnson
02-12-2008, 04:22 PM
Can you show your actual query ?

Brandoe85
02-12-2008, 04:27 PM
You can use the LEFT function:

select fields from table where left(field, 1) = 'C'
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_left