Abdelakbir El Ghazouani Abdelakbir El Ghazouani - 6 months ago 80
MySQL Question

sql select in table grammage

+----+------------+---------+-----------+
| id | type_id | grammage| price |
+----+------------+---------+-----------+
| 1 | 1 | 20 | 44 |
| 2 | 1 | 50 | 80 |
| 3 | 1 | 100 | 110 |
| 4 | 1 | 250 | 180 |
| 5 | 1 | 500 | 250 |
+----+------------+---------+-----------+


I want to select price per grammage
Exemple : select 150 gram

Answer Source

using laravel database builder:

$weight = DB::table('weight')->where('grammage', '150')->first();

echo $weight->price;

https://laravel.com/docs/5.5/queries#selects

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download