keiG Posted October 22, 2012 Report Share Posted October 22, 2012 Īsti pat nezinu, kā to googlē atrast, jo izskaidrot laikam varu tikai šādi, Tabulas: Product => id, name, price, category_id, subcategory_id, saler_id, u.c ar id Salers => id, name, utt Category => id, name Subcategory => id, name, cat_id un citas tabulas Tātad nepieciešams meklētājs, bet kāds būs mysql pieprasījums, lai meklē tādus datus no product tabulas, ja tajos pārsvarā ir dati ar id numuriem? Quote Link to comment Share on other sites More sharing options...
daGrevis Posted October 22, 2012 Report Share Posted October 22, 2012 ... LEFT JOIN `category` ON `category`.`id` = `product`.`category_id` WHERE `category`.`name` LIKE "%Alus%" ... ...idejiski. Ceru, ka sintakse ir pareiza — pēdējā laikā vispār neizmantoju “raw SQL“. :) Quote Link to comment Share on other sites More sharing options...
keiG Posted October 23, 2012 Author Report Share Posted October 23, 2012 (edited) SELECT `wholesalers`.`name` as `saler`, `category`.`name` as `cat`, `subcategory`.`name` as `subcat`, `users`.`name` as `usr` FROM `wholesalers`,`category`,`subcategory`,`users` INNER JOIN `saler` ON `products`.`wholesaler` = `saler`.`id` INNER JOIN `cat` ON `products`.`category` = `cat`.`id` INNER JOIN `subcat` ON `products`.`subcategory` = `subcat`.`id` INNER JOIN `usr` ON `products`.`salesagent` = `usr`.`id` Atradu inner join kas cik sapratu aizvieto tos id ar nosaukumu, bet kaut kas tur neiet. Vismaz idejiski uzkodēju domu. Ceru ka ir saprotams. Edited October 23, 2012 by keiG Quote Link to comment Share on other sites More sharing options...
mad182 Posted October 23, 2012 Report Share Posted October 23, 2012 Ja tu JOIN'o klāt tabulu, tad neliec to pie FROM. Quote Link to comment Share on other sites More sharing options...
keiG Posted October 23, 2012 Author Report Share Posted October 23, 2012 Tāpat neiet! Quote Link to comment Share on other sites More sharing options...
daGrevis Posted October 23, 2012 Report Share Posted October 23, 2012 «Left», ne «inner». Quote Link to comment Share on other sites More sharing options...
daGrevis Posted October 23, 2012 Report Share Posted October 23, 2012 Un ko nozīmē neJiet? Errors, nav rezultāts? Quote Link to comment Share on other sites More sharing options...
keiG Posted October 23, 2012 Author Report Share Posted October 23, 2012 (edited) SELECT `products`. *, `wholesalers`.`name`, `category`.`name`, `subcategory`.`name`, `users`.`name` FROM `products` LEFT JOIN `wholesalers` as `saler` ON `products`.`wholesaler` = `saler`.`id` LEFT JOIN `category` as `cat` ON `products`.`category` = `cat`.`id` LEFT JOIN `subcategory` as `subcat` ON `products`.`subcategory` = `subcat`.`id` LEFT JOIN `users` as `usr` ON `products`.`salesagent` = `usr`.`id` #1054 - Unknown column 'wholesalers.name' in 'field list' Edited October 23, 2012 by keiG Quote Link to comment Share on other sites More sharing options...
Kavacky Posted October 23, 2012 Report Share Posted October 23, 2012 Let me google.translate that for you. Quote Link to comment Share on other sites More sharing options...
keiG Posted October 23, 2012 Author Report Share Posted October 23, 2012 (edited) Nu ja Tev vajadzīga google, lai to iztulkotu, tad Tev ir serious brain damage! Errors lec uz visām tabulām! Ja tev vajag tabulu izrakstu, tad varu nošērot un tad varēsi mest googlē un tulkot! Edited October 23, 2012 by keiG Quote Link to comment Share on other sites More sharing options...
daGrevis Posted October 23, 2012 Report Share Posted October 23, 2012 Ja tev sagādā problēmas tas errors, tev ir jādomā par profesijas maiņu! Quote Link to comment Share on other sites More sharing options...
keiG Posted October 23, 2012 Author Report Share Posted October 23, 2012 (edited) Īpašiem cilvēkiem - http://failiem.lv/th...em.png Kā man riebjās cilvēki, kam ir tik sakāpis, ka pilnīgi spiežās cauri! Ka tikai kādam kaut ko uzbraukt un aizvainot! Pilnīgi riebjās šitie latviešu forumi un cilvēki, kas atbildes vietā labāk uzbrauc! Edited October 23, 2012 by keiG Quote Link to comment Share on other sites More sharing options...
v3rb0 Posted October 23, 2012 Report Share Posted October 23, 2012 hint: vai tāds wholesalers.hide un wholesalers.id ir? tie ar blakus 'name' :> Quote Link to comment Share on other sites More sharing options...
keiG Posted October 23, 2012 Author Report Share Posted October 23, 2012 Es apmēram neko nesapratu, ko Tu jautā! Ja Tu domā tabulas: wholesalers, utt un kolonnas: id, name, hide ir visiem! Quote Link to comment Share on other sites More sharing options...
xPtv45z Posted October 23, 2012 Report Share Posted October 23, 2012 Īpašiem cilvēkiem - http://failiem.lv/th...em.png Kā man riebjās cilvēki, kam ir tik sakāpis, ka pilnīgi spiežās cauri! Ka tikai kādam kaut ko uzbraukt un aizvainot! Pilnīgi riebjās šitie latviešu forumi un cilvēki, kas atbildes vietā labāk uzbrauc! Mums tāpat, varbūt, riebjās cilvēki, kas paši nemaz nedomā, tikai kaut ko uz labu laimi dara un cer, ka viss strādās, bet ja nestrādā skrien uzreiz uz forumu. Jo tas ko tu tur tagad dari, ir lipini kaut kādus atrastus koda gabalus kopā, nemaz neiedziļinoties ko viņi dara. Un pēc tam pārējie ir vainīgi, ka visu priekšā neparāda. Lai gan, ko tu tur kautrējies un mokies, dod tik šurp visu, kas tev ir jākodē, mēs jau tikai priekšā tā vien šeit esam, lai citu vietā visu izdarītu. hint: mysql alias 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.