|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Help needed with JOINS and WHERE
Hi, I hope someone can help.
I have the following statement I am trying to get output from: SELECT craft.craftID, craft.boatname, customers.fname, customers.lname FROM (craft INNER JOIN ownership ON craft.craftID=ownership.craftID)INNER JOIN customers ON ownership.customerID=customers.customerID WHERE craft.boatname LIKE 'Mighty' This is linking 3 tables: Craft craftID boatname 1 Mighty Max 2 Sudoku Customers customerID firstname lastname 1 Bob Newman 2 Joe Blogs Ownership autoinc craftID CustomerID 1 1 1 2 1 2 3 2 2 As you can see there can be a many to many relationship hence the complication... What I need as an output is the boatnames with customers but being able to reduce the number of returns but adding the LIKE clause so if it is LIKE 'mig' it will only return the 2 lines showing Mighty Max The statement without the WHERE ... LIKE ... returns all the lines as expected, it just seems like the WHERE is not working... Whenever it is added nothing is returned!??!? Hope someone can help. Kind regards Jason |
|
#2
|
|||
|
|||
|
You need to add %'s to your search word, depending on which way you want to search.
WHERE craft.boatname LIKE '%Mig'
__________________
-- Jason |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > Help needed with JOINS and WHERE |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|