Quick basic SQL questions

Message Bookmarked
Bookmark Removed
Ive forgotten the basics so help me out. What is the command for displaying an entire table and what is the command for displaying 2 tables with a common field? Also, how do you list all the tables? THX

sunny successor (he hates my guts, we had a fight) (katharine), Tuesday, 6 September 2005 23:36 (twenty years ago)

try
1 - select * from (table)
2 - select A.field, B.field, (other fields) from table A, table B where A.field = B.field

3 - depends on the database (vendor)
select * from all.tables
select * from all.table.columns (where tablename = (table)

when something smacks of something (dave225.3), Tuesday, 6 September 2005 23:47 (twenty years ago)

sweet! thanks

sunny successor (he hates my guts, we had a fight) (katharine), Tuesday, 6 September 2005 23:52 (twenty years ago)

ILX is the new google

my name is john. i reside in chicago. (frankE), Wednesday, 7 September 2005 00:28 (twenty years ago)

Longer-than-you-probably-wanted-answer to #2 can be found at Joins 101: http://www.onjava.com/pub/a/onjava/2004/01/07/SQLJoins.html

(mmm inner vs outer and so forth)

lyra (lyra), Wednesday, 7 September 2005 02:25 (twenty years ago)

eight years pass...

what's wrong with this:

CREATE TABLE client(
emp_id INT(8) AUTO_INCREMENT,
client_name VARCHAR(60) NOT NULL,
dept_id INT(4) NOT NULL,
email VARCHAR(40),
PRIMARY KEY (emp_id),
FOREIGN KEY (dept_id) REFERENCES department(dept_id)
);

is it that i can't reference a foreign key until the other table is created?

because that would suck because i can't create any of them without referencing other tables.

if it's something else, i'd be much obliged.

james lipton and his francs (darraghmac), Monday, 28 April 2014 00:03 (eleven years ago)

Yeah I think you'd have to add it after the other one's been created. ALTER TABLE if memory serves

corn binary, Monday, 28 April 2014 00:22 (eleven years ago)

perfect, i can at least try a workaround on that

cheers

quick q: if i created all tables in the one file and read it in, would the same apply?

james lipton and his francs (darraghmac), Monday, 28 April 2014 00:37 (eleven years ago)

Oh yeah, you could just add the ALTER statements later in the file.

corn binary, Monday, 28 April 2014 00:44 (eleven years ago)

i was hoping if i read it all in one, the engine or w/e would handle the statements in place

:(

that seems a somewhat glaring oversight but i only started studying this today eh whadoo i know

james lipton and his francs (darraghmac), Monday, 28 April 2014 00:45 (eleven years ago)

Wooo, did I call that?!

she started dancing to that (Finefinemusic), Monday, 28 April 2014 02:30 (eleven years ago)


You must be logged in to post. Please either login here, or if you are not registered, you may register here.