Jump to content

MySQL Queries


DavidKing0r

Recommended Posts

Hi. I have a rather large database and i require to search 'Short Item Name' for keywords (2/3 words). Not all 3 words need to be in each result. Also I'd like to know how I would search 'Number' for a partial match so if one of the records 'Number' was 098214984212 and I entered 4984212 (last 7) into a form how would i retrieve that record?

 

Thanks really appreciate if anyone helps me out.

 

dave

Link to comment
https://forums.phpfreaks.com/topic/278104-mysql-queries/
Share on other sites

Thanks i gathered that having a bit of trouble now though. Heres what I have in my Table for example.

 

No             | Short Name        | Long Name 
21421414 | Treble blah tree | Treble tree with a blah ring

52352352 | wqe weqwe         | wqe weqwe weqrqwr rwqr qw

 

Im now trying to search the short name with 

 

$query = "SELECT * FROM DB WHERE 'Short Item Name' LIKE '%$searchTerm1%' AND '%$searchTerm2%'";

 

 

However it doesnt appear to work any ideas?

Link to comment
https://forums.phpfreaks.com/topic/278104-mysql-queries/#findComment-1430715
Share on other sites

To elaborate a tad further, you often see this:

 

select `something` from `someplace` where `some_condition` = 1234;
Those are "backticks", and people that use them use them in order to make sure that their SQL server, (MySQL in this case, and especially) doesn't choke on any terms.

 

For example, you can use a reserved word as a column name, but only if you enclose it in backticks. I tend NOT to use them, and to (properly, I believe) refrain from using SQL Reserved Words as column names.

 

HTH,

Link to comment
https://forums.phpfreaks.com/topic/278104-mysql-queries/#findComment-1430749
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.