Toymods Car Club
www.toymods.org.au
F.A.Q. F.A.Q.    Register Register    Login Login    Home Home
Members Members    Search Search
Toymods » The Outhouse » HELP! SQL Query for Uni...

Show: Today's Posts  :: Show Polls 
Email to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
AuthorTopic
ZZT231
Forums Junkie


I Supported Toymods

Location:
melbourne.vic.au
Registered:
May 2002
HELP! SQL Query for Uni... Tue, 28 October 2003 03:24 Go to next message
Hey All,

My teacher said that I could not use MS Access as my Query Generator and I have to use my brain Confused

Query is:

SELECT RepairLog.*, Techicians.chargeperhour FROM Techicians INNER JOIN (PCDetails INNER JOIN RepairLog ON PCDetails.pc_id = RepairLog.pc_id) ON Techicians.techicians_id = RepairLog.techicians_id

Can anyone be able to convert it to standard SQL (Without mentioning Inner Join)?

Cheers.
  Send a private message to this user    
ehendrikd
Forums Junkie


Location:
ballarat
Registered:
April 2003
 
Re: HELP! SQL Query for Uni... Tue, 28 October 2003 06:06 Go to previous messageGo to next message
rough gestimate, but ill give it a try...

select repairlog.*, technicians.chargeperhour from technicians, (select * from pcdetails, repairlog where pcdetails.pc_id = repairlog.pc_id) where technicians.technicians_id = repairlog.technicians_id

im not big on databases, but maybe it'll steer you in the right direction Very Happy
  Send a private message to this user    
Nark
Forums Junkie


Location:
Cabramatta, NSW
Registered:
May 2002
      Nark@toymods.net/Work
icon2.gif  Re: HELP! SQL Query for Uni... Tue, 28 October 2003 09:40 Go to previous messageGo to next message
Getting others to do your assignments for you? No No No

You're only cheating yourself.
  Send a private message to this user    
ZZT231
Forums Junkie


I Supported Toymods

Location:
melbourne.vic.au
Registered:
May 2002
Re: HELP! SQL Query for Uni... Tue, 28 October 2003 21:35 Go to previous messageGo to next message
ehendrikd,

Thanks for the Query... I will try it out...

Nark, thanks for your opinion and it's true. I am cheating myself but after all, if the program is nearly finished, by completely changing the query means I would have to change the function of the program, it's too late to alter the program Confused

Cheers.
  Send a private message to this user    
ZZT231
Forums Junkie


I Supported Toymods

Location:
melbourne.vic.au
Registered:
May 2002
Re: HELP! SQL Query for Uni... Tue, 28 October 2003 21:38 Go to previous messageGo to next message
PS: In TAFE, I never learnt how to do a nested SQL Statement Smile and in Uni I got excempted from the SQL subject Very Happy

Cheers
  Send a private message to this user    
SupraPete
Forums Junkie


Location:
Sydney
Registered:
July 2002
   
Re: HELP! SQL Query for Uni... Tue, 28 October 2003 23:55 Go to previous messageGo to next message
how do you do an inner join in "Standard SQL"? I can write it in sql for oracle.

also, always structure your SQL statements nicely. Start the Select/from/where/and on a new line.


SELECT RepairLog.*, Techicians.chargeperhour
FROM Techicians, RepairLog, PCDetails
WHERE RepairLog.technicians_id = Technicians.technicians_id
AND PcDetails.pc_id &= RepairLog.pc_id

note: some databases use *= or other ways defining innner joins.

I don't understand the statement though as why are you inner joining PCDetails if your not using it to link to another table and your not using any of the details in there. Is it just selecting the ones that actually have some PCDetails? If so then the above statement should work (without a database to test it on who knows??).
  Send a private message to this user    
ZZT231
Forums Junkie


I Supported Toymods

Location:
melbourne.vic.au
Registered:
May 2002
Re: HELP! SQL Query for Uni... Wed, 29 October 2003 06:14 Go to previous messageGo to next message
Thanks HKSPete,

I thought of doing it but hell... I didn't know why I didn't use that simple statement you wrote up Embarassed.

Thanks for that...

Cheers.
  Send a private message to this user    
SupraPete
Forums Junkie


Location:
Sydney
Registered:
July 2002
   
Re: HELP! SQL Query for Uni... Wed, 29 October 2003 06:45 Go to previous messageGo to next message
No probs Smile


Just remember to set it out nicely for a start, it is SOOOO much easyer to see whats happening and so quicker to find whats wrong. Especially when you start getting SQL statements that are stupidly long (I've seen a few that were 1 and a half pages long BEFORE being set out nicely! Shocked )
  Send a private message to this user    
gtman
Forums Junkie


Location:
Perth
Registered:
November 2002
Re: HELP! SQL Query for Uni... Thu, 30 October 2003 02:41 Go to previous messageGo to next message
you'd have to be some kind of masochist to write an sql statement that long Confused
  Send a private message to this user    
SupraPete
Forums Junkie


Location:
Sydney
Registered:
July 2002
   
Re: HELP! SQL Query for Uni... Thu, 30 October 2003 02:49 Go to previous messageGo to next message
Or want something specific done on a large database.
  Send a private message to this user    
ehendrikd
Forums Junkie


Location:
ballarat
Registered:
April 2003
 
Re: HELP! SQL Query for Uni... Thu, 30 October 2003 05:32 Go to previous messageGo to next message
was i close hkspete? we use an application framework, so i havent had to do any sql queries in a while. Smile
  Send a private message to this user    
SupraPete
Forums Junkie


Location:
Sydney
Registered:
July 2002
   
icon13.gif  Re: HELP! SQL Query for Uni... Thu, 30 October 2003 05:53 Go to previous message
ehendrikd wrote on Tue, 28 October 2003 17:06

select repairlog.*, technicians.chargeperhour from technicians, (select * from pcdetails, repairlog where pcdetails.pc_id = repairlog.pc_id) where technicians.technicians_id = repairlog.technicians_id


You didn't format it nicely Mad Smile

I don't think you need another select though (and why are you selecting *?), your not assigning the values to anything.

I think the whole inner statement is in the wrong spot. I think it should be after the where clause.

You havn't got a from for repairlog in your first select statement

I don't know what database its written for and don't think it will work.



SQL is relative to the database its to be run on, so your code (and my code) could run on some databases and not on others.

  Send a private message to this user    
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic:Who went to the ministry of sound tour
Next Topic:Rugby World Cup
Goto Forum:
-=] Back to Top [=-

Current Time: Sun Dec 22 02:07:17 UTC 2024

Total time taken to generate the page: 0.0069038867950439 seconds

Bandwidth utilization bar

.:: Contact :: Home ::.

Powered by: FUDforum 2.3.8
Copyright ©2001-2003 Advanced Internet Designs Inc.