Jump to content

setting one column equal to another column when using two tables


darga333

Recommended Posts

Hi I am trying to set t1.sImagePath=t2.sImagePath and it is not working for some reason

This code selects what I need
[code]SELECT t1.sImagePath,t2.sImagePath FROM members t1, discount t2 WHERE t1.bBusiness = 1 AND t1.user_id = t2.iMemberId AND t2.sActive = 1 GROUP BY t1.user_id[/code]

does anyone know how to do that?
Link to comment
Share on other sites

[quote]
Starting with MySQL Version 4.0.4, you can also perform UPDATE operations that cover multiple tables:

UPDATE items,month SET items.price=month.price
WHERE items.id=month.id;

The example shows an inner join using the comma operator, but multiple-table UPDATE statements can use any type of join allowed in SELECT statements, such as LEFT JOIN.

Note: you cannot use ORDER BY or LIMIT with multiple-table UPDATE.

[/quote]
Link to comment
Share on other sites

Hey for some reason it is giving me the following error:

#1064 - You have an error in your SQL syntax near '
discount SET members.sImagePath = 'discount.sImagePath' WHERE memb' at line 1

UPDATE members,discount SET members.sImagePath='discount.sImagePath' WHERE members.user_id = discount.iMemberId

does anyone know what i am doing wrong?

Link to comment
Share on other sites

it still gives me the same error

I dont understand what I could be doing wrong

I have it set up exactly how you are saying

UPDATE members,discount SET members.sImagePath=discount.sImagePath WHERE members.user_id = discount.iMemberId

i am trying to set members.sImagePath = discount.sImagePath ... could it possibly be because I set members.sImagePath as null when i created the column?

Link to comment
Share on other sites

Hey Barand, do you know of a way with the older version of mysql? I am going to upgrade mysql but at a later date.

I did several searches online and tried to come up with a solution before replying back to this topic. I have another question also. It said that i was tryign to do was a multiple table update when infact I am just updating 1 table. Maybe you might know why that is?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.