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!

SELECT problem 2

Status
Not open for further replies.

JuRo

Programmer
Nov 24, 2002
5
AT
hi 2 all!
can i SELECT information from a mysql without knowing the whole information in a field?

lets say the data in table "table", field "field" is "a, b, c". i want to SELECT the data with

SELECT * from table WHERE field = X

the SELECT command should show the data whether i replace X by a, b or c ....

i am using mysql and php. i hope this described my problem, if not please tell me!

i am looking forward to your suggestions

JuRo
 
If I understand you correctly, "Field" is a string, and you want to be able to select based on a substring? Try the following:

SELECT * from table WHERE field LIKE "%X%"

Where X is what you want to find within the field. For example,


TABLE - BOOKS
FIELDS - ISBN, TITLE, PRICE
DATA:
ISBN TITLE PRICE
01012 MySQL For Dummies 10.50
12373 PHP and MySQL Development 37.25
01297 PHP Web Applications 15.95

Soething like:

Select * from BOOKS where TITLE like "%MySQL%"

will bring back the two books that include MySQL in the title.
--
How can you be in two places at once when you're not anywhere at all?
 
@mweinstock

thanx.
works like a charm ...

JuRo
 
Thanks! --
How can you be in two places at once when you're not anywhere at all?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top