SunQuest
 
           MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old October 22nd, 2007, 01:52 PM
jellmers jellmers is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 1 jellmers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 14 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old October 25th, 2007, 02:32 PM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 364 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 26 sec
Reputation Power: 6
You need to add %'s to your search word, depending on which way you want to search.

WHERE craft.boatname LIKE '%Mig'
__________________
-- Jason

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > Help needed with JOINS and WHERE


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway