I have this 2 following SQL Queries on my grails controller:
def query1 = sql.rows("select abc from table_one where cond = 1")
The return result from query1 gives me [{abc=5}]
def query2 = sql.rows("select req from table_two where abc = " +query1)
I am having an error trying to run query2 and I have no idea why.
the column name abc
exist in both table_one
and table_two
, I am trying to fetch the value of abc
from table_one
, whereby cond = 1
, and assign it to variable query1.
and with query2, I am trying to get the values of req
from table_two
, whereby the value of abc
in table_two
is equals to the value of query1.
any help on this?
Error message from query2:
Message:Unclosed quotation mark after the character string '[abc:5]'.
You join the table using INNER JOIN
select b.req
from table_one a
INNER JOIN table_two b
ON a.abc = b.abc
where a.cond = 1
the following syntax is ANSI SQL-92
.