Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
TorspeR
Starting Member
11 Posts |
Posted - 2010-09-17 : 03:12:19
|
| Hello,I'm new to SQL and got a little problem here.I previously made a query such as this one:SELECT nimi, kausi, paketit.paketti, (`elikpl`*`ylimenmin_hinta`) AS ylimmin_hinta FROM tyontekijat INNER JOIN paketit ON tyontekijat.paketti = paketit.paketti INNER JOIN jyypalv_helmi ON tyontekijat.uid = jyypalv_helmi.uid WHERE paketit.paketti = 'elisa1200'This one worked but I made another one which didn't and it had the same inner joins:SELECT nimi, kausi, jyypalv_helmi.paketti, (`pakhinta`+(`elisasmsm`*`elisakolsms`)+(`saunalsmsm`*`saunasms`)+(`muutsmsm`*muutsms)+(`elisamulm`*`elisakolmul`)+(`saunamulm`*`saunamul`)+(`muutmulm`*`muutmul`)+(`spostimulm`*`spostimul`)) AS Kulut FROM tyontekijat, sms_hinnat, multim_hinnat INNER JOIN paketit ON tyontekijat.paketti = paketit.paketti INNER JOIN jyypalv_helmi ON tyontekijat.uid = jyypalv_helmi.uidI don't get what the problem is, this query returns:#1054 - Unknown column 'tyontekijat.paketti' in 'on clause'If someone has a solution to my problem, feel free to post it here. :D |
|
|
rohitvishwakarma
Posting Yak Master
232 Posts |
Posted - 2010-09-17 : 04:18:17
|
| Try this:SELECT nimi, kausi, jyypalv_helmi.paketti, (`pakhinta`+(`elisasmsm`*`elisakolsms`)+(`saunalsmsm`*`saunasms`)+(`muutsmsm`*muutsms)+(`elisamulm`*`elisakolmul`)+(`saunamulm`*`saunamul`)+(`muutmulm`*`muutmul`)+(`spostimulm`*`spostimul`)) AS Kulut FROM sms_hinnat, multim_hinnat , tyontekijatINNER JOIN paketit ON tyontekijat.paketti = paketit.pakettiINNER JOIN jyypalv_helmi ON tyontekijat.uid = jyypalv_helmi.uid |
 |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2010-09-17 : 04:57:21
|
Does the below really look right to you?FROM tyontekijat, sms_hinnat, multim_hinnatINNER JOIN paketit ON tyontekijat.paketti = paketit.pakettiINNER JOIN jyypalv_helmi ON tyontekijat.uid = jyypalv_helmi.uid Where are the join conditions for sms_hinnat & multim_hinnat? What are they supposed to join to? Are they INNER JOINS, OUTER JOINS or CROSS JOINS? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-09-17 : 11:50:51
|
| seems like you're mixing old and new join syntaxes...I cant spot the joins conditions though------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
TorspeR
Starting Member
11 Posts |
Posted - 2010-09-20 : 03:43:22
|
Thanks rohitvishwakarma.. your solution solved my problem. I really can't see why it has to be like you said but it works, heh. |
 |
|
|
rohitvishwakarma
Posting Yak Master
232 Posts |
Posted - 2010-09-20 : 04:00:14
|
quote: Originally posted by TorspeR Thanks rohitvishwakarma.. your solution solved my problem. I really can't see why it has to be like you said but it works, heh.
Always Welcome |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-09-21 : 12:13:02
|
quote: Originally posted by TorspeR Thanks rohitvishwakarma.. your solution solved my problem. I really can't see why it has to be like you said but it works, heh.
Hope you're aware that whatever you've on top is taking cross join (cartesian product) between three tables which i'm not sure is what you're looking at really------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|