rootKID Posted October 4, 2012 Share Posted October 4, 2012 this is my SQL: SELECTprodukter.p_id,produkter.p_titel,produkter.p_kunstner,produkter.p_oprettet,image_url.img_url,genre.g_navn,priser.pr_prisFROMprodukter INNER JOIN produkter ON produkter.p_FK_pris = priser.pr_id INNER JOIN image_url ON image_url.img_FK_products = produkter.p_id INNER JOIN genre ON produkter.p_FK_genre = genre.g_id and i cannot see what the heck is wrong... ideas?...and how to fix ect Oo... Link to comment Share on other sites More sharing options...
niche Posted October 4, 2012 Share Posted October 4, 2012 What error message do you get? Link to comment Share on other sites More sharing options...
justsomeguy Posted October 4, 2012 Share Posted October 4, 2012 You're joining the table with itself, you need to give one or both of them an alias so it knows which one you're talking about in the join conditions. 1 Link to comment Share on other sites More sharing options...
niche Posted October 4, 2012 Share Posted October 4, 2012 (edited) Table alias. Not something I've used before that's why I was following. http://www.w3schools...l/sql_alias.asp Zehr gut. Edited October 4, 2012 by niche Link to comment Share on other sites More sharing options...
rootKID Posted October 4, 2012 Author Share Posted October 4, 2012 (edited) hello, and sorry for late reply,... as useally... but JSG... i agree that i have to give them aliases... but i cannot just type (produkter AS p)... right?... or am i wrong .. anyways... i just really need this one to work, and i have no clue on what to do from now on here... or, at least with this peace of junk SQL ...ideas?... i mean, i was trying to use (SQL-FlySpeed) Program to make the SQL start for me... faster, and easier when im to the exams...then i can cut some time and spend more of the time to the coding part ... but about the code, i was trying to make with flyspeed, and instead of (produkter) then it said (genre)... and i could not do a damn thing....because its a shop-kind of website we are going to make... so i need to take from the (produkter/shop) table... ideas?... EDIT: and yes... i can see where the thing is going wrong... but to make a innerjoin, then i (need) to write a table first (INNER JOIN table)... right?... Edited October 4, 2012 by rootKID Link to comment Share on other sites More sharing options...
justsomeguy Posted October 4, 2012 Share Posted October 4, 2012 but i cannot just type (produkter AS p)... right?Why not? Link to comment Share on other sites More sharing options...
rootKID Posted October 4, 2012 Author Share Posted October 4, 2012 (edited) SQL: SELECTprodukter.p_id,produkter.p_titel,produkter.p_kunstner,produkter.p_oprettet,image_url.img_url,genre.g_navn,priser.pr_pris,produkter AS pFROMp INNER JOIN produkter ON produkter.p_FK_pris = priser.pr_id INNER JOIN image_url ON image_url.img_FK_products = produkter.p_id INNER JOIN genre ON produkter.p_FK_genre = genre.g_id Gives: Table 'svende_prove.p' doesn't exist... that is why...:/... Edited October 4, 2012 by rootKID Link to comment Share on other sites More sharing options...
justsomeguy Posted October 4, 2012 Share Posted October 4, 2012 Well, if you did it correctly, then it would work. Yeah, it's not going to work if you don't do it right. Why do you have the table alias in the list of fields to select? It's not a field, it's a table. SELECTp1.p_id,p1.p_titel,p1.p_kunstner,p1.p_oprettet,image_url.img_url,genre.g_navn,priser.pr_prisFROMprodukter AS p1INNER JOIN produkter AS p2 ... Link to comment Share on other sites More sharing options...
rootKID Posted October 5, 2012 Author Share Posted October 5, 2012 (edited) ohh.... crap... my bad :/... will test and give feedback... -thanks... EDIT: this is what i get.... (Unknown column 'priser.pr_pris' in 'field list')... so now its working at least... but the fun part is that i have copy/pasted from the DB itself... so i know for sure that i have (NOT) spelled wrong...ideas?... SQL: SELECTp1.p_id,p1.p_titel,p1.p_kunstner,p1.p_oprettet,image_url.img_url,genre.g_navn,priser.pr_prisFROMprodukter AS p1 INNER JOIN produkter ON p1.p_FK_pris = priser.pr_id INNER JOIN image_url ON image_url.img_FK_products = p1.p_id INNER JOIN genre ON p1g.p_FK_genre = genre.g_id Edited October 5, 2012 by rootKID Link to comment Share on other sites More sharing options...
justsomeguy Posted October 5, 2012 Share Posted October 5, 2012 The priser table needs to be included in the join list. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now