Answer the question
In order to leave comments, you need to log in
How to make a query with a text string (literal string) in yii2 query builder?
Need a query like this
SELECT CategoryID, CategoryName, 'Northwind Category' AS Note
FROM categories;
$query = (new \yii\db\Query())
->select("CategoryID, CategoryName, CONCAT('Northwind Category', '' ) AS Note")
->from('categories');
Answer the question
In order to leave comments, you need to log in
1) Use the string concatenation function of your DBMS
$query = (new \yii\db\Query())
->select("CategoryID, CategoryName, CONCAT('Northwind Category', '' ) AS Note")
->from('categories');
$query = (new \yii\db\Query())
->select([
'CategoryID',
'CategoryName',
'Note' => new \yii\db\Expression("'Northwind Category'")])
->from('categories');
$query= (new \yii\db\Query())
->from('categories')
->where(['Note' => 'Northwind Category'])
->all();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question