|
| [MySQL] 2 selects til samme tabel - den en~ Fra : Kim Schulz |
Dato : 31-05-04 10:14 |
|
hejsa
jeg sidder or roder med en ordredatabase, men er stødt ind i et
underligt problem.
jeg har en tabel order_items hvorfra jeg skal have en del data ud.
laver jeg
"select * from order_items" så får jeg fint alle data ud.
Gør jeg det imidlertid som :
SELECT
p.name AS name,
o.qty AS qty,
o.product_id AS pid,
o.price AS price
FROM
o.order_items,
p.products
WHERE
order_id=39
AND o.product_id=p.pid
Så får jeg:
select command denied to user: dbadmin@localhost for table order_items
hvordan kan det lige gå til?
--
Kim Schulz | Need a Content Management System for your website? Go
Geek by nature | get Fundanemt at : http://www.fundanemt.com New
schulz.dk | version out now!
| |
Troels Arvin (31-05-2004)
| Kommentar Fra : Troels Arvin |
Dato : 31-05-04 11:02 |
|
On Mon, 31 May 2004 11:14:00 +0200, Kim Schulz wrote:
> FROM
> o.order_items,
> p.products
> select command denied to user: dbadmin@localhost for table order_items
Du har formuleret din SQL forkert, og MySQL tror, at du prøver at benytte
data i nogle databaser kaldet "o" og "p".
Prøv noget i stil med følgende, som jeg ikke har testet:
SELECT
p.name AS name,
o.qty AS qty,
o.product_id AS pid,
o.price AS price
FROM
order_items AS o,
products AS p
WHERE
order_id=39
AND o.product_id=p.pid
--
Greetings from Troels Arvin, Copenhagen, Denmark
| |
Kim Schulz (31-05-2004)
| Kommentar Fra : Kim Schulz |
Dato : 31-05-04 11:19 |
|
On Mon, 31 May 2004 12:02:11 +0200
Troels Arvin <troels@arvin.dk> wrote:
> On Mon, 31 May 2004 11:14:00 +0200, Kim Schulz wrote:
>
> > FROM
> > o.order_items,
> > p.products
>
> > select command denied to user: dbadmin@localhost for table
> > order_items
>
> Du har formuleret din SQL forkert, og MySQL tror, at du prøver at
> benytte data i nogle databaser kaldet "o" og "p".
>
> Prøv noget i stil med følgende, som jeg ikke har testet:
>
> SELECT
> p.name AS name,
> o.qty AS qty,
> o.product_id AS pid,
> o.price AS price
> FROM
> order_items AS o,
> products AS p
> WHERE
> order_id=39
> AND o.product_id=p.pid
>
yep det var fejlen... takker
--
Kim Schulz | Stop Software patents before it is too late!
Geek by nature |
schulz.dk |
| |
|
|