Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
legend986
Forum Contributor
Posts: 258 Joined: Sun Jul 15, 2007 2:45 pm
Post
by legend986 » Sat Oct 20, 2007 12:17 am
I have two tables:
Table Name: table1
Table Rows: a b
Table Name: table2
Table Rows: a b c d e f
Initially c of table2 is empty. I want to actually fill it up from table1 using some statement like:
Code: Select all
UPDATE table2 SET c={SELECT a FROM table1 WHERE b=d}
Where d belongs to table2.
Is this possible?
Charles256
DevNet Resident
Posts: 1375 Joined: Fri Sep 16, 2005 9:06 pm
Post
by Charles256 » Sat Oct 20, 2007 1:29 am
Change the { into ( and } into ). Next question, have you tried it? I suspect if you had you wouldn't be asking the question
( hint. it's called subqueries if you're using google to find more information about it ).
legend986
Forum Contributor
Posts: 258 Joined: Sun Jul 15, 2007 2:45 pm
Post
by legend986 » Sat Oct 20, 2007 1:30 am
I was actually typing that I figured out the solution when I got your reply
Thanks for the information... Realized my mistake...