fieldname | datatype | len | default | not null?
titles | varchar | 250 | ‘’ | Y
sourcenames | varchar | 250 | ‘’ | Y
DESTINATION TABLE:
table name - datato
fieldname | datatype | len | default | not null?
titles | varchar | 250 | ‘’ | Y
names | varchar | 250 | ‘’ | Y
VALUES in datafrom
titles | sourcenames
Admin | Mike
Supervisor | Cory
User | Danny
VALUES in datato
titles | sourcenames
| Mike
| Cory
| Danny
I want to move “titles” data from “datafrom” into “titles” in “datato”, starting with the same row the user “Mike” is on and so on.
I tried:
UPDATE a
SET a.titles = b.titles
FROM datato a INNER JOIN datafrom b ON a.sourcenames = b.sourcenames
I received error:
Query : UPDATE a SET a.titles = b.titles FROM datato a INNER JOIN datafrom b ON a.sourcenames = b.sourcenames
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘FROM datato a INNER JOIN datafrom b ON a.sourcenames = b.sourcenames’ at line 3
Execution Time : 00:00:00:000
Transfer Time : 00:00:00:000
Total Time : 00:00:00:000
That would be with an UPDATE statement since you don’t want to add new rows.
What you haven’t explained well enough is how you decide which title should be updated with an existing row in your current table and that is where you are having the problem.
except you wouldn’t want to actually run that, because you already have that table – what’s important is the actual table and columns, the structure of the table
try it again with a table with more columns and at least one index
and of course this is way better than a screenshot because now i can copy the CREATE TABLE statement and run it on my system – with screenshots i would have to retype everything, which i prolly wouldn’t bother to do
In the example you gave me earlier, it updated the rows, not added, but the “ON datato.id = datafrom.id” added a common value between the two, perhaps I need to find one, like import the threadid’s into that source table and then run the query…
Well, the source column has “title” and the target column in another table has “title” and some other columns, I just see that “ON datato.id = datafrom.id” statement but I was worried about running that when my actual production tables, there is no “id” column in the source table, only the “price” column if taking the column names from your example…