Idag har jag denna kod i en liten sökfunktion mot en access databas.
strSQL = "SELECT Forums.PK_ForumId, Forums.Name, Replies.PK_ReplieId, Replies.FK_TopicId, Replies.From, "_
&"Replies.Inserted, Replies.Content, Topics.PK_TopicId, Topics.FK_ForumId, Topics.From, Topics.Header, "_
&"Topics.Content, Topics.Inserted "_
&"FROM (Forums INNER JOIN Topics ON Forums.PK_ForumId = Topics.FK_ForumId) "_
&"left outer JOIN Replies ON Topics.PK_TopicId = Replies.FK_TopicId "_
&"WHERE Topics.Header LIKE '%"& strSearch &"%' OR Topics.Content LIKE '%"& strSearch &"%' "_
&" OR Replies.Content LIKE '%"& strSearch &"%' OR Topics.From LIKE '%"& strSearch &"%' "_
&" OR Replies.From LIKE '%"& strSearch &"%'"
Problemet är att jag har en topic som har 5 svar, olle har skrivit topicen och postat 2 svar, om jag söker på olle så kommer alla fem inlägg + topicen upp eftersom han finns i bägge. Måste jag skriva 2 sql frågor?
1. Söker igenom tabellen Topics och skriver ut dem
2. Söker igenom tabellen Replies och skriver ut dem
eller går det att lösa med någon skum sql kod :) LarsG kanske har ett enkelt svar som alltid ;)
------------------
Real mad hiphop flavaz kickin' it right from tha street without no FEAR, Yo !