Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 根据下拉列表中的选择名称获取项目的代码_Mysql - Fatal编程技术网

Mysql 根据下拉列表中的选择名称获取项目的代码

Mysql 根据下拉列表中的选择名称获取项目的代码,mysql,Mysql,我表中的数据如下所示 Name | Code | Quantity | Prod1 | PR.01.14 | 100 | Prod1 | PR.01.13 | 1000 | Prod2 | PR.02.14 | 200 | Prod2 | PR.02.13 | 2000 | 我希望发生的是,当用户在下拉列表中选择Prod1时,它将

我表中的数据如下所示

Name    |   Code        |   Quantity    |
Prod1   |   PR.01.14    |   100         |
Prod1   |   PR.01.13    |   1000        |
Prod2   |   PR.02.14    |   200         |
Prod2   |   PR.02.13    |   2000        |
我希望发生的是,当用户在下拉列表中选择Prod1时,它将显示该名称的代码

Name    |   Code        |   Quantity    |
Prod1   |   PR.01.14    |   100         |
Prod1   |   PR.01.13    |   1000        |

都在同一张桌子上。如何执行此操作?

您需要从表中获取所有列,并使用WHERE子句按从下拉列表中选择的名称进行筛选

select Name,
Code,
Quantity 
from my_code_table
where Name = 'Prod1'