Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL] Kolumna jest dwuznaczna
lukko
post
Post #1





Grupa: Zarejestrowani
Postów: 49
Pomógł: 0
Dołączył: 12.03.2009

Ostrzeżenie: (10%)
X----


Układam sobie zapytanie do oscommerce:

Kod
$pytanie = tep_db_query("SELECT shops_id, products_id, stock, shops_name FROM shops_stocks INNER JOIN shops ON (shops_stocks.shops_id = shops.shops_id) WHERE products_id = '" . (int)$product_info['products_id'] . "';");


Łącze dwie tabele jak opisano: http://it.dth.pl/select-from-inner-join-ri...ql-mysql-cz-4c/ :-)

Wywala mi:

1052 - Column 'shops_id' in field list is ambiguous


Nie wiem jak ten błąd obsłużyć, jakaś sugestia ?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 6)
piotrooo89
post
Post #2


Newsman


Grupa: Moderatorzy
Postów: 4 005
Pomógł: 548
Dołączył: 7.04.2008
Skąd: Trzebinia/Kraków




poczytaj o aliasach.
Go to the top of the page
+Quote Post
nospor
post
Post #3





Grupa: Moderatorzy
Postów: 36 559
Pomógł: 6315
Dołączył: 27.12.2004




no mysql nie wie z ktorej tabeli ty te shops_id chcesz brac.
nie:shops_id
tak:shops.shops_id
Go to the top of the page
+Quote Post
lukko
post
Post #4





Grupa: Zarejestrowani
Postów: 49
Pomógł: 0
Dołączył: 12.03.2009

Ostrzeżenie: (10%)
X----


Chce ze shops_stocks

Czyli jak załączyć tą tabele ON (shops_stocks.shops_id = shops.shops_id) - zły ten warunek ale jak by miał wyglądać poprawnie?

W tym moim zapytaniu:

Kod
$pytanie = tep_db_query("SELECT shops_id, products_id, stock, shops_name FROM shops_stocks INNER JOIN shops ON (shops_stocks.shops_id = shops.shops_id) WHERE products_id = '" . (int)$product_info['products_id'] . "';");
Go to the top of the page
+Quote Post
phpion
post
Post #5





Grupa: Moderatorzy
Postów: 6 072
Pomógł: 861
Dołączył: 10.12.2003
Skąd: Dąbrowa Górnicza




Nie chodzi o złączenie, tylko o fragment SELECT shops_id, products_id. Daj *

* albo sam pokombinuj (IMG:style_emoticons/default/tongue.gif)

Ten post edytował phpion 3.12.2009, 13:39:21
Go to the top of the page
+Quote Post
nospor
post
Post #6





Grupa: Moderatorzy
Postów: 36 559
Pomógł: 6315
Dołączył: 27.12.2004




warunek zlaczenia masz ok. Mi chodzilo o select
tak ma byc:
SELECT shops_stocks.shops_id,.....
a dalej jak bylo
Go to the top of the page
+Quote Post
lukko
post
Post #7





Grupa: Zarejestrowani
Postów: 49
Pomógł: 0
Dołączył: 12.03.2009

Ostrzeżenie: (10%)
X----


Aaaa dzięki wielkie a ja się czepiałem warunku (IMG:style_emoticons/default/smile.gif) nospor poszło dzia...
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 4.10.2025 - 19:33