根据单列中的值选择列
对于 MySQL 来说,我是个十足的新手。我在这里和其他地方做了一些搜索,但未能找到一些我认为非常简单的东西。
我有一个电子邮件程序,可以从 MySQL 数据库导入字段/列以用于批量电子邮件。
我只想导入在表中特定列中具有特定值的用户的信息。
要导入我通常使用的所有用户:
SELECT firstname, email FROM users
我尝试将其修改为:
SELECT firstname, email FROM users WHERE group = "test"
其中 group
是我尝试测试的列的名称,test
是我正在寻找的价值。我认为这可能很接近,但它会带来错误。
有人能帮我纠正一下吗?
I am complete newbie when it comes to MySQL. I have done some searching around here and elsewhere, but haven't been able to work out something that I imagine is very simple.
I have an email program that imports fields/columns from a MySQL database for bulk emails.
I am wanting to only import information for users that have a particular value in a particular column in a table.
To import all users I would normally use:
SELECT firstname, email FROM users
I have tried amending this to:
SELECT firstname, email FROM users WHERE group = "test"
where group
is the name of the column that I am trying to test against, and test
is the value I am searching for. I think this might be close, but it brings up an error.
Could someone put me straight?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你的问题是group是MySQL中的一个关键字。您可以使用
使用反引号来引用字段名称。
I think your problem is that group is a keyword in MySQL. You can use
Use back ticks to quote field names.