Go Back  DVD Talk Forum > General Discussions > Tech Talk
Reload this Page >

Pls help a n00b with using SQL in Microsoft Access...

Tech Talk Discuss PC Hardware, Software, Internet and Other Technology

Pls help a n00b with using SQL in Microsoft Access...

Old 02-01-04, 06:46 PM
  #1  
DVD Talk Legend
Thread Starter
 
Join Date: Oct 1999
Location: |-|@><0r [email protected]|)
Posts: 17,214
Likes: 0
Received 0 Likes on 0 Posts
Pls help a n00b with using SQL in Microsoft Access...

I've just gotten my first dose of SQL, and it's pretty cool. I'm using it to manage an Access database, and I have two questions:

1) I'd love a command-line interface for executing SQL commands, but I can't find one in Access. The closest I've found is SQL View in query design mode, but this is *much* less useful: every statement you execute shows the query results, and you have to go back into design view to execute the next statement. Am I missing something?

2) In SQL, is there an easy way to dereference a foreign-key field?

Say I have Table1 containing a string called Name, and Table2 containing a (many-to-one) reference to Table1.Name. When I try to select the Table2 names, like this:

SELECT (whatever) FROM Table2 WHERE Name='David Stein';

...I get an empty result. Now, I know why: the Name column in Table2 doesn't actually contain the name strings, but rather integers that correspond to the primary-key entries (ID) in Table1. So I can do this:

SELECT (whatever) FROM Table1, Table2 WHERE Table1.Name = Table2.ID AND Table2.Name = 'David Stein';

or with a join:

SELECT (whatever) FROM Table1 JOIN Table2 AT Table1.Name = Table2.ID WHERE Table2.Name = 'David Stein';

...but these are both horribly more complicated. In fact, I'm just looking for an easy way to dereference the Name references in Table1. Does anything like this exist?

Thanks a lot...

- David Stein
Old 02-01-04, 08:37 PM
  #2  
DVD Talk Hall of Fame
 
Join Date: Jan 2000
Location: US
Posts: 9,631
Likes: 0
Received 0 Likes on 0 Posts
Any particular reason you are using access over getting something like MySQL and using that to learn?

As for your answer, your second statement is probably your best best. Not really a way to shorten it from there much.
dave
Old 02-01-04, 11:08 PM
  #3  
DVD Talk Legend
Thread Starter
 
Join Date: Oct 1999
Location: |-|@><0r [email protected]|)
Posts: 17,214
Likes: 0
Received 0 Likes on 0 Posts
Originally posted by Dave99
Any particular reason you are using access over getting something like MySQL and using that to learn?
I already have a bunch of data in Access for work, so I'm practicing my SQL skills by manipulating it. Not much more reason than that.

I'll probably need more, though - can you recommend a good, free MySQL server for WinXP?
Originally posted by Dave99
As for your answer, your second statement is probably your best best. Not really a way to shorten it from there much.
dave
Rats. I'm too used to C... I just wanna do *(Table1.Name) to dereference it.

Seriously, though - why tf isn't a simple dereferencing construct supported, anyway?

- David Stein
Old 02-01-04, 11:41 PM
  #4  
DVD Talk Hero
 
Join Date: Aug 2000
Location: Bartertown due to it having a better economy than where I really live, Buffalo NY
Posts: 29,706
Likes: 0
Received 0 Likes on 0 Posts
I've just recently started using access, and dont' remember much of my sql from the database class I took a few years ago, but from what I've found so far, access, at least the version I have, isn't really made for use with sql
I'm not knocking access, I just think, from my experience so far, that it was designed to be used differently from using sql
Old 02-02-04, 09:44 AM
  #5  
DVD Talk Hall of Fame
 
Join Date: Jan 2000
Location: US
Posts: 9,631
Likes: 0
Received 0 Likes on 0 Posts
Free sql:
http://www.mysql.com
You could set that up, and import your data from access. Like mikehunt said, using access to learn SQL probably isn't a good idea.
dave

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Thread Tools
Search this Thread

Archive - Advertising - Cookie Policy - Privacy Statement - Terms of Service - Do Not Sell My Personal Information

Copyright 2018 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.