Update one table from another within MySQL, via DBVIS SQL commander - mysql

I have adapted the solutions already posted on this question to my task but it is still generating the error:
Unknown column testbr.Tel in 'field list'
UPDATE `Test_file_base_record_subset` `testbr`
INNER JOIN `UKTI_16sep15` `ukti`
ON `ukti.UKTI_Short_UID`=`testbr.ShortUID`
SET `testbr.Tel` = `ukti.UKTI_Tel`
WHERE `testbr.Year`=2015
Please tell me where I am going wrong. Thanks.

UPDATE `Test_file_base_record_subset` `testbr`
INNER JOIN `UKTI_16sep15` `ukti` ON `ukti`.`UKTI_Short_UID`=`testbr`.`ShortUID`
SET `testbr`.`Tel` = `ukti`.`UKTI_Tel`
WHERE `testbr`.`Year`=2015

Related

mySQL pre-8.x Stack Overflow 'solution' not working?

Hello and thank you for any help you can provide.
I am running on a shared-server platform so I am restricted to using mySQL version 5.6.46 which means I do not have access to "recursive CTE" and "WITH" commands . After many hours of looking for a solution for how I can perform a recursive-type operation - and after trying many approaches that did not end up working - I found this Stack Overflow reference to an approach that seems like a reasonable method for what I am trying to accomplish (and simple enough for someone at my level of understanding). The method described can be found about 1/4 of the way down the page under the title of "Alternative 3: Repeated Self-joins."
In essence, I have copied the entire recommended mySQL query and modified it to my table structure BUT it triggers an error and does not run.
The error is "#1054 - Unknown column 'p2.id' in 'on clause'" which - according to my internet searches - is a common error with many references BUT each refers refers to a two-table structure with a 'comma' that - based on a SQL update years ago now requires parentheses to make it work. I am puzzled with this error on my end because I DO NOT have a two-table structure. I can find no other reason for this error. In fact, on the https://www.piliapp.com/ syntax checker it shows the syntax is fine. I would appreciate your eyes on this query to see what I'm missing. Here is my code:
select p4.ManagerID as parent4_id,
p3.ManagerID as parent3_id,
p2.ManagerID as parent2_id,
p1.ManagerID as parent_id,
p1.EmployeeID as employee_id,
p1.LastName
from cps_db_sm7.dEmployees p1
left join cps_db_sm7.dEmployees p2 on p2.id = p1.ManagerID
left join cps_db_sm7.dEmployees p3 on p3.id = p2.ManagerID
left join cps_db_sm7.dEmployees p4 on p4.id = p3.ManagerID
where 23578 in (p1.ManagerID,
p2.ManagerID,
p3.ManagerID,
p4.ManagerID)
ORDER BY 1,2,3,4,5;
The error is triggered by the first LEFT JOIN and is in reference to the ON p2.id. Could someone please look at this and suggest a solution? Thank you!

ER_BAD_FIELD_ERROR: Unknown column 'table.column' in 'on clause'

i'm getting a really confused problem... i'm triying to do a query:
SELECT ordenes_servicio.idorden, estatus_orden.descripcion AS estatus, tipo_orden.descripcion AS tipo_orden, usuario.nombre, ordenes_servicio.nombres_cliente, ordenes_servicio.fecha_asig
FROM ordenes_servicio
INNER JOIN estatus_orden ON ordenes_servicio.idestatus_orden = estatus_orden.idestatus_orden
INNER JOIN tipo_orden ON ordenes_servicio.idtipo_orden = tipo_orden.idtipo_orden
INNER JOIN usuario ON ordenes_servicio.id = usuario.id
ORDER BY ordenes_servicio.idorden DESC
The problem is that when i try to run it, it say
ER_BAD_FIELD_ERROR: Unknown column 'ordenes_servicio.idusuario' in
'on clause'
But if you look at the query, there is no 'ordenes_servicio.idusuario', and yes there was, but i update my tables, both of them, and it is like the query is still triying to get that column.
When i execute the query in my MySQL Workbench it work, but dont when i try to run it in my application... Someone can help me? :/
Note: my "app" is actually a REST API in typescript, and i'm using express library
I got the answer... if can help a beginner like me someday. Im actually executing three querys, and there was one of then that still had "ordenes_servicio.idusuario"... that's all.. So check your querys!
Beginner error...

MySQL UPDATE query styntax error

I am trying to update a year column in MySQL with the following query:
UPDATE PUB.oa_inthed
SET PUB.oa_inthed.yearno ='2016'
WHERE PUB.oa_intnom.intid = 'XC352332'
but keep receiving this error:
[AnyDAC][Phys][ODBC][DirectData][ODBC Progress OpenEdge Wire Protocol driver][OPENEDGE]Syntax error in SQL statement at or about ".oa_inthes.yearno ='2016' WHERE PUB.oa" (10713)
Can someone point me in the right direction as to what is going wrong?
Thanks in advance
if oa_inthed is the table name then just specify it once and again table name in WHERE doesn't match as of UPDATE statement. Your query should look like
UPDATE PUB.oa_inthed
SET yearno ='2016'
WHERE PUB.oa_intnom.intid = 'XC352332'
^........... This should be oa_inthed
I think this is problem
UPDATE PUB.oa_inthed
SET PUB.oa_inthed.yearno ='2016'
WHERE PUB.oa_inthed.intid = 'XC352332'
oa_intnom = oa_inthed
in where clause..

Update a column on a table from a table on another schema MySql

I accidentally updated far more records than I should have with the wrong information. I have the correct information in another schema but I cannot figure out how to update the incorrect one.
I've tried something like -
Insert into schema1.table1 set columnName = (Select statement????) Where ?????
And then I get lost.
I've read around and tried a few answers out and I keep either getting a syntax error, or nothing happens.
Any help would be appreciated.
update schema1.table1
inner join schema2.table2
on schema1.table1.IDColumn = schema2.table2.IDColumn
set schema1.table1.column1 = schema2.table2.column2
This Worked for me

SQL unknown column when doing join

I have been getting an error "Unknown column 'guests_guest.id' in 'field list'" when i try to run the following:
SELECT guests_guest.id
FROM `guests_guest` full join
guests_guest_group
on guests_guest.id=guests_guest_group.guest_id
All the column& table names are correct. in fact, running just
SELECT guests_guest.id
FROM `guests_guest`
works just fine. I suspect there is a syntax issue I am missing. what am I doing wrong?
try:
SELECT gg.id
FROM `guests_guest` as gg
join guests_guest_group as ggg
on ggg.guest_id=gg.id
assuming guests_guest_group does not have an id column.
full join ?
Have you tried simply removing the full?
This not Oracle, it's MySQL, right? AFAIK, FULL JOIN is not implemented yet in MySQL.
The parser (because "full' is not a keyword it knows), evaluates your query as:
SELECT guests_guest.id
FROM guests_guest AS full <--- crucial note
JOIN guests_guest_group
ON guests_guest.id = guests_guest_group.guest_id
After that, guests_guest is not a name it knows, but it uses full as an alias for table guests_guest. That's why this error is produced.
If you really need FULL JOIN and not (INNER) JOIN, then search SO for how to implement FULL JOIN in MYSQL.
#rockerest: I guest so.
Two things I'd look at:
Spelling... I am a fast typer, but sometimes my fingers are dyslexic. Worst case, do a describe on each table and check column names against each other. Or, use the system-confessed column names and copy/paste.
Aliases... but, someone else has mentioned that.
So I guessed just one thing.