SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


HOW TO JOIN 2 DIFFERENT MYSQL TABLES WITH A SQL TABLE


HOW TO JOIN 2 DIFFERENT MYSQL TABLES WITH A SQL TABLE

Author
Message
koen_huys
koen_huys
Grasshopper
Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)

Group: General Forum Members
Points: 19 Visits: 78
I have the following query, I have 3 tables
in the first tabel1 (tester.f_artclient) there are 3 colums : name, sellingprice, categorie (sql table)
in the second tabel (tabel2) (mysql) I have the following colums :model, product
in the third tabel (Tabel3) (mysql) I have the following colums: product, price and custumer_group

finally what i want is that the sellingprice from tabel1 comes into price from table 3

I get an error in 'from' on line 5



update tabel3

set dt.price = tabel1.ac_prixVen
from openquery (mysqlapp, 'select * from product_special') as tabel3
inner join (from openquery(mysqlapp,'select * from product') as tabel2
inner join
tester.f_artclient as tabel1
on tabel2.model = tabel1.name collate
database_default where c.ac_categorie = '1'
and tabel2.price <>tabel1.sellingprice) as dt on
tabel3.product = dt.product
collate database_default
where tabel3.customer_group = '1'
and tabel3.price<> tabel1.ac_prixVen

can somebody help we what I am doing wrong
Evil Kraig F
Evil Kraig F
SSCrazy Eights
SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)

Group: General Forum Members
Points: 8545 Visits: 7660
What's the error, and can you describe the linked server you're calling mysqlapp?


- Craig Farrell

Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

For better assistance in answering your questions | Forum Netiquette
For index/tuning help, follow these directions. |Tally Tables

Twitter: @AnyWayDBA
koen_huys
koen_huys
Grasshopper
Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)

Group: General Forum Members
Points: 19 Visits: 78
I found it, now it works,

update tabel3

set tabel3.price = dt.ac_prixVen
from openquery (mysqlapp, 'select * from product_special') as tabel3
inner join (select Ar_ref, Ac_prixVen, AC_categorie,product_id, price
from openquery (mysqlapp, 'select * from product') as tabel2 inner join
tractov15.dbo.f_artclient as tabel1
on tabel2.model = tabel1.ar_ref where tabel1.ac_categorie = '1'
) as dt on
tabel3.product_id = dt.product_id
where tabel3.customer_group_id = '1'
and tabel3.price<> dt.ac_prixVen

the mysqlapp is a linked server for mysql, and at this point my prices de prices in mysql are updated by the prices of sql
thanks
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search