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

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old May 26th, 2000, 08:49 AM
starspider starspider is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 3 starspider User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi,

i search in one table for a certain keyword. Each record can be connected (can be!) with data in another table, done by joins. So, now somebody searchs in my table and finds a records. He gets the information via a dynamic website but one piece of information is from the second table, but it must not be always a second piece of information. And here is my problem: If I find a record by searching the table with a keyword i dont get any output if the second information in the second table is not there, there is just no entry. How can i get the query (joins) not to care for the second information in the second table?? Please help...

$query = "SELECT links.*, counter.* FROM links, counter WHERE (links.name LIKE '%" . $suchwort_search . "%' OR links.link LIKE '%" . $suchwort_search . "%' OR links.besch LIKE '%" . $suchwort_search . "%' OR links.suchworte LIKE '%" . $suchwort_search . "%') AND (links.frei = 1) OR (links.id = counter.id AND counter.date = '2000-05-26') ORDER BY counter.hits, links.average, links.clicks DESC LIMIT $pos, $count";
Its a long query i know URL) Everything works fine if there are two identical IDs in both tables, but if not the query doesnot select a record.

Reply With Quote
  #2  
Old May 29th, 2000, 09:12 PM
esconsult esconsult is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 43 esconsult User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Joins can be a little hairy, but consider your SQL statement:

SELECT <fields> FROM <table1>, <table2> WHERE <joincondition> AND <other where>

You should convert it to look like this:

select <fields> from <table1>,<table2> LEFT JOIN <table2> ON <table1.id=table2.id> WHERE <your other where conditions>;


------------------
PHP, Perl, SQL Programming at http://www.mentalobjects.com

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Joins


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 1 hosted by Hostway