I am trying to enter a query with a field 'Convert (aes_encrypt ())' and also use it as a variable in a subquery.

$string = 'CONVERT(AES_DECRYPT(d.column, "key")USING utf8)';
$query = db_select('demo' 'd');
$query->field('d', $string);

And use this at once as a sub query

$query->condition($string, $subquery, 'IN');

Thank you


You want an expression for the selected field:

$query = db_select('demo' 'd');
$query->addExpression($string, 'd');

I'm not sure what you're going for with the sub query bit, if you update the question with the desired SQL it should be straightforward to tell you whether it's possible with a SelectQuery.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.