Hi Tischbein,
I think I can help you with the first part. Where I use aliases a and b which are assigned in the FROM clause, you can simply use tablename.fieldname (if you enjoy typing and eyestrain).
I assume that you agree that all table fields should be declared as "not null" as there is a lot of grief to be gained from allowing null data in tables. Testing for null or not being equal to null in result tables has validity. Selecting a.* below would return all fields in the yin table and b.* display all fields from the yang table [ select yin.*, yang.* ]. A plain select * from multiple tables will succeed only if the fieldnames are unique between the two tables.
Selecting * is not good practice as the order of the fields is often as declared in the table definition, but you can catch a crab if someone changes a table definition by adding another field and occasionally an upgrade to a new dbms version can false foot you too. If you are explicit with what fields you wish to display, you will at least ignore an added field or get an error if the fieldname is changed; perhaps someone spelled it incorrectly and decided to clean it up before you went to final test and production! The display field names can be changed like this:
Code:
SELECT a.id AS myyinid, a.name AS forename
This is what you want though -
Code:
SELECT a.id, a.name
FROM yin.a, yang b
WHERE a.id = b.yin_id
If you must use SELECT * , then you can I believe refer to col1, col2, col3 etc in the output, as long as some joker hasn't false footed you with a change somewhere.
This is all untested but believed to be good; my experience was mainly as an Ingres dbms application developer.
Just noticed your second post and can't figure where the > 45 came into the equation?
Not entirely sure I understand your requirement in the second part of your question. Good luck.
No real recommendation for a book, but you could either try the MySQL documentation or have a look at the documentation downloads for Open Ingres. There are a lot of pdf manuals that can be downloaded and the SQL ones while not being MySQL are pretty much ansi SQL. A good starting point at no cost and a rich source of examples. I appreciate that MySQL will do a lot more, but time enough for the power stuff when you have a firm grip on the SQL for free
Good hunting, keep digging at the code-face.
PAix