Mysql 列的行以另一行的值开头
我有一个如下表:
MyTable
--------
A
B
C
A、B、C 是列,MyTable 是表名,我想运行一个 mysql 查询,如下所示:
SELECT MT1.A, MT2.A, MT2.B FROM MyTable MT1, MyTable MT2
WHERE MT1.B<>MT2.B and MT2.B like "MT1.B%" and MT2.status=0;
正如您从上面的查询中看到的,我有一个表,我想找到以另一个表开头的列rows 值并匹配条件。但上面的查询显然失败了,因为mysql将“MT1.B%”作为字符串,我如何用Mysql实现这一点?
I have a table like below:
MyTable
--------
A
B
C
A,B,C are columns and MyTable is the table name and i want run a mysql query like:
SELECT MT1.A, MT2.A, MT2.B FROM MyTable MT1, MyTable MT2
WHERE MT1.B<>MT2.B and MT2.B like "MT1.B%" and MT2.status=0;
As you see from the query above i have a table and i want find the columns that starts with another rows value and matches the conditions. But above query obviously fails because mysql takes "MT1.B%" as a string, how can i achieve this with Mysql?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该能够执行以下操作:
You should be able to do the following: