[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: SQL Q's.
Aaron Turner wrote:
> 1) When selecting a row for updating, the quickest way to select it is by
> the primary key. True? Are there times when you wouldn't want to use the
> primary key?
I would assume that to be the case, yeah. Jason would probably answer this
better than I.
> 2) How to you write a SQL statement to select the fields from rows in a
> table based on the value of another field in the table. Ie:
>
> SELECT CategoryID,CategoryName,Description FROM Categories WHERE Approved
> = 'Y'
Exactly.
> 3) How do I insert a row in a table for which the primary key is
> auto-incrementing or not auto-inc?
When it auto-incs, I believe you can just leave that field out of your list.
> 3) How do I update one or more fields in a row?
UPDATE tablename SET fieldname = 'value'
That will set that field in EVERY record. Add the WHERE clause just like in
SELECT to specify which rows to update.
> 4) How do I update one field in multiple rows based on a value of a field
> in that row?
See above.
> 5) Anyone know any good SQL sites? Something like SQL for Dummies?
Not really... I just use a college SQL textbook. A flimsy one at that. I know
that there's an SQL Unleashed that looks *somewhat* cool...
--
"But whatever was to my profit I now consider loss for the sake of Christ.
What is more, I consider everything a loss compared to the surpassing
greatness of knowing Christ Jesus my Lord, for whose sake I have lost all
things. I consider them rubbish, that I may gain Christ." Philippians 3:7-8
- References:
- SQL Q's.
- From: Aaron Turner <aturner@linuxkb.org>