daviskrex Posted September 18, 2009 Report Share Posted September 18, 2009 (edited) Sveiki, tātad, mēģināju uzcept search skriptu, bet saskāros ar tādu problēmu, ka man vajadzētu kaut kā noteikt no kura table rezultāts ir, jo meklēšana notiek vairākos table'os. SELECT * From news,forum_posts,forum_topics, members where news.virsraksts like \"%$qsql%\" or news.raksts like \"%$qsql%\" or forum_topics.title like \"%$qsql%\" or forum_posts.teksts like \"%$qsql%\" or forum_posts.title like \"%$qsql%\" or members.profile_name like \"%$qsql%\" or members.email like \"%$qsql%\" or members.name like \"%$qsql%\" or members.surname like \"%$qsql%\" order by news.id, forum_topics.id, forum_posts.id, members.id desc Varbūt kāds var dot kādu padomu kā šo īstenot? Jau iepriekš pateicos. Edited September 18, 2009 by daviskrex Quote Link to comment Share on other sites More sharing options...
bubu Posted September 18, 2009 Report Share Posted September 18, 2009 Tasīt dekarta reizinājumu no visu tabulu ierakstiem, ir drusku aplami... Var izmantot, piemēram, UNION'u: SELECT "news", virsraksts FROM news WHERE virsraksts LIKE "%qsql%" UNION SELECT "forum_topics", title FROM forum_topics WHERE title LIKE "%qsql%" UNION ... Vienīgi ierobežojums, ka visiem SELECT'iem jāatgriež vienāds kolonnu skaits. Daudz prātīgāk arī ir neizmantot LIKE keywordu, bet tā vietā taisīt full text search'u: http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html Quote Link to comment Share on other sites More sharing options...
codez Posted September 18, 2009 Report Share Posted September 18, 2009 taisi 4 kverijus, katrai tabulai savu. Quote Link to comment Share on other sites More sharing options...
daviskrex Posted September 18, 2009 Author Report Share Posted September 18, 2009 taisi 4 kverijus, katrai tabulai savu. Jā, laikam tavs variants šeit vislabāk derēja. Paldies! :) Quote Link to comment Share on other sites More sharing options...
Kemito Posted September 18, 2009 Report Share Posted September 18, 2009 Es labāk būtu izvēlējies bubu variantu! Quote Link to comment Share on other sites More sharing options...
daviskrex Posted September 19, 2009 Author Report Share Posted September 19, 2009 Lieta tāda, ka es īsti nesapratu, kā ar to full text searču var nolasīt teiblu, kurā ieraksts atrodas... Būtu jau ļoti forši, ja varētu uztaisīt pēc tā labākā varianta :) Quote Link to comment Share on other sites More sharing options...
bubu Posted September 19, 2009 Report Share Posted September 19, 2009 Fulltext search's to neatrisina. Fulltext search tikai aizvieto LIKE keyworda lietošanu. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.