# Is it possible to send a value together with Sql JOIN and AND operator?

**URL:** <https://discourse.laminas.dev/t/is-it-possible-to-send-a-value-together-with-sql-join-and-and-operator/1933>\
**Category:** Components & MVC\
**Tags:** laminas-db\
**Created:** [November 7, 2020, 12:57pm UTC](https://discourse.laminas.dev/t/is-it-possible-to-send-a-value-together-with-sql-join-and-and-operator/1933 "2020-11-07T12:57:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eguvenc](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/eguvenc/32/265_2.png) [@eguvenc](https://discourse.laminas.dev/u/eguvenc)\
**Post date:** [November 7, 2020, 12:57pm UTC](https://discourse.laminas.dev/t/is-it-possible-to-send-a-value-together-with-sql-join-and-and-operator/1933/1 "2020-11-07T12:57:54Z")

</div>

I want to send a language id value that is valid only in the joined table.

```php
        $sql = new Sql($this->adapter);
        $select = $sql->select();
        $select->from('users');
        $select->columns([
            'user_id',
        ]);
        $select->join(['s' => 'specifications'], 'u.client_id = s.client_id AND u.user_id = s.consultant_id', 
                       ['specification_id'], $select::JOIN_LEFT);
        $select->join(['sl' => 'specifications_lang'], 
        	's.client_id = sl.client_id AND s.specification_id = sl.specification_id AND sl.lang_id = ?',
        	$select::JOIN_LEFT
        ); 
        $statement = $sql->prepareStatementForSqlObject($select);
        $resultSet = $statement->execute(['en']);

```

But quote identifiers not allow to send values into join clause.

```auto
SELECT `users`.`user_id` AS `user_id`, `s`.`specification_id` AS `specification_id`, `sl`.`left` AS `left` FROM `users` LEFT JOIN `specifications` AS `s` ON `u`.`client_id` = `s`.`client_id` AND `u`.`user_id` = `s`.`consultant_id` INNER JOIN `specifications_lang` AS `sl` ON `s`.`client_id` = `sl`.`client_id` AND `s`.`specification_id` = `sl`.`specification_id` AND `sl`.`lang_id` = `?`

```

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [November 10, 2020, 8:59am UTC](https://discourse.laminas.dev/t/is-it-possible-to-send-a-value-together-with-sql-join-and-and-operator/1933/2 "2020-11-10T08:59:14Z")

</div>

If you want to call a function or add parameters then look at the allowed types of the second parameter of the method `join`. There you will find `string` and `Laminas\Db\Sql\Expression`. The last one will help you.

---

<div class="post-metadata">

**Author:** ![eguvenc](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/eguvenc/32/265_2.png) [@eguvenc](https://discourse.laminas.dev/u/eguvenc)\
**Post date:** [November 10, 2020, 1:24pm UTC](https://discourse.laminas.dev/t/is-it-possible-to-send-a-value-together-with-sql-join-and-and-operator/1933/3 "2020-11-10T13:24:07Z")

</div>

Thanks !. Do i need to write identifiers as manually or is there any solution for this ?

```php
        $expression = new Expression(
            '`s`.`client_id` = `sl`.`client_id` AND `s`.`symptom_id` = `sl`.`symptom_id` AND `sl`.`lang_id` = ?',
            [LANG_ID]
        );        
        $select->join(['sl' => 'symptoms_lang'], $expression,['symptom_name', 'description'], $select::JOIN_LEFT);

```

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [November 10, 2020, 1:50pm UTC](https://discourse.laminas.dev/t/is-it-possible-to-send-a-value-together-with-sql-join-and-and-operator/1933/4 "2020-11-10T13:50:39Z")

</div>

> [@eguvenc](#):
>
> …is there any solution for this ?

Please have a look at the “[platform object](https://docs.laminas.dev/laminas-db/adapter/#using-the-platform-object)”.
