Ask Your Question
0

parameterized query to mysql from base for subform [closed]

asked 2012-08-17 20:29:48 +0100

jnnewton gravatar image

I'm tring to figure out how to parameterize queries in base. I have the follwing that runs on mysql directly:

SET @var = 1155;
SELECT i.*, t.name
FROM items i
LEFT JOIN item_tags it ON it.item_id = i.id
LEFT JOIN tags t ON it.tag_id = t.id
WHERE i.id=@var;

That query will not run on base(syntax errors), the closest i can get is:

SELECT i.*, t.name
FROM items i
LEFT JOIN item_tags it ON it.item_id = i.id
LEFT JOIN tags t ON it.tag_id = t.id
WHERE i.id=?;

Where i receive: "The data content could not be loaded. Value not set for all parameters" I need some more information on how to make this work, what the actual proper syntax is, and how to specify the parameters.

I am direct connected to the mysql db, and am running the sql "directly"

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2015-10-17 20:02:01.485960

1 Answer

Sort by » oldest newest most voted
0

answered 2012-08-17 23:39:14 +0100

jnnewton gravatar image

updated 2012-08-17 23:39:58 +0100

Answer:

SELECT "i".*, "t"."name" 
FROM "items" "i" 
LEFT JOIN "item_tags" "it" ON "it"."item_id" = "i"."id" 
LEFT JOIN "tags" "t" ON "it"."tag_id" = "t"."id" 
WHERE ( "i"."id" = :var )

Run SQL Command Directly : no

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-08-17 20:29:48 +0100

Seen: 754 times

Last updated: Aug 17 '12