HOW TO JOIN 2 DIFFERENT MYSQL TABLES WITH A SQL TABLE

  • 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

  • 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[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • 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

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply