table1 在 table1.varchar 上连接 table2 等于 prefix+table2.numeric_id+suffix

阿尔门·齐鲁尼扬

我正在编写以下查询:

SELECT * FROM notes inner join item_source 
 on notes.item_ids=CONCAT(CONCAT(',', cast(item_source.id as varchar(10))), ',')

item_source.id是table的主键(数字,auto_increment)item_sourcenotes.item_idsvarchar表注释字段。

我想item_source.id=18匹配notes.item_ids= ',18,'

我收到以下错误:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'varchar(10))), ',')

我究竟做错了什么?

公羊

您需要将其转换为 char 数据类型,然后您才能得到结果

SELECT * FROM notes内连接item_source on notes.item_ids=CONCAT(CONCAT(',', cast(item_source.id as char(10))), ',')

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如果 table1 中的 table2 id 不为空,如何加入 table2

来自分类Dev

显示来自table1的数据,其中其id(Table1 Id)未包含在table2中

来自分类Dev

来自table1,table2的多列左连接

来自分类Dev

使用准备好的语句根据 table1 计算 table2 上的行

来自分类Dev

SQL table1 row_id不显示table2 row_id

来自分类Dev

Select ONE random row from Table1 where id does not exist in Table2

来自分类Dev

DAX:对table1中的行进行计数,其中1列中的数据等于table2中的数据,并将总和返回给table2

来自分类Dev

如何从“ TABLE1 AND TABLE2”创建SELECT查询

来自分类Dev

SQL - 从 table2 更新 table1 值

来自分类Dev

选择 table1 和 table2 的计数

来自分类Dev

连接2个表,其中table2每个table1行包含多个行

来自分类Dev

如果整行不存在于 table2 中,则插入 table2 从 table1 中选择

来自分类Dev

MySQL SELECT * FROM table1,table2,table3

来自分类Dev

当table1匹配table2并且table 2行包含特定级别时,使用特定值更新table1上的特定行

来自分类Dev

使用staging_table1和table2中的数据插入table1,同时使用staging_table1从table2中获取数据

来自分类Dev

使用staging_table1和table2中的数据插入table1,同时使用staging_table1从table2中获取数据

来自分类Dev

SQL Server matching all rows from Table1 with all rows from Table2

来自分类Dev

将table2中的所有行插入到table1中

来自分类Dev

MYSQL:重复table1内容乘以table2中的内容

来自分类Dev

如何从table2中提取最接近table1的DATE FIELD的数据?

来自分类Dev

错误table1与table2不关联cakephp3

来自分类Dev

javascript:单击table1列幻灯片以显示table2列

来自分类Dev

从table2更新table1(插入新的,仅更新已更改,删除缺失)

来自分类Dev

仅当table1中存在类似记录时才插入到table2中

来自分类Dev

仅显示table1中与table2不同的字段(SQL Server 2008)

来自分类Dev

在mysql中选择子查询,其中table2是table1的一列

来自分类Dev

mysql union select where table1 field3 = table2 field5

来自分类Dev

Laravel - 用 table2 列更新 table1 列

来自分类Dev

如何从 table1 中获取不在 table2 中的数据?代码点火器

Related 相关文章

  1. 1

    如果 table1 中的 table2 id 不为空,如何加入 table2

  2. 2

    显示来自table1的数据,其中其id(Table1 Id)未包含在table2中

  3. 3

    来自table1,table2的多列左连接

  4. 4

    使用准备好的语句根据 table1 计算 table2 上的行

  5. 5

    SQL table1 row_id不显示table2 row_id

  6. 6

    Select ONE random row from Table1 where id does not exist in Table2

  7. 7

    DAX:对table1中的行进行计数,其中1列中的数据等于table2中的数据,并将总和返回给table2

  8. 8

    如何从“ TABLE1 AND TABLE2”创建SELECT查询

  9. 9

    SQL - 从 table2 更新 table1 值

  10. 10

    选择 table1 和 table2 的计数

  11. 11

    连接2个表,其中table2每个table1行包含多个行

  12. 12

    如果整行不存在于 table2 中,则插入 table2 从 table1 中选择

  13. 13

    MySQL SELECT * FROM table1,table2,table3

  14. 14

    当table1匹配table2并且table 2行包含特定级别时,使用特定值更新table1上的特定行

  15. 15

    使用staging_table1和table2中的数据插入table1,同时使用staging_table1从table2中获取数据

  16. 16

    使用staging_table1和table2中的数据插入table1,同时使用staging_table1从table2中获取数据

  17. 17

    SQL Server matching all rows from Table1 with all rows from Table2

  18. 18

    将table2中的所有行插入到table1中

  19. 19

    MYSQL:重复table1内容乘以table2中的内容

  20. 20

    如何从table2中提取最接近table1的DATE FIELD的数据?

  21. 21

    错误table1与table2不关联cakephp3

  22. 22

    javascript:单击table1列幻灯片以显示table2列

  23. 23

    从table2更新table1(插入新的,仅更新已更改,删除缺失)

  24. 24

    仅当table1中存在类似记录时才插入到table2中

  25. 25

    仅显示table1中与table2不同的字段(SQL Server 2008)

  26. 26

    在mysql中选择子查询,其中table2是table1的一列

  27. 27

    mysql union select where table1 field3 = table2 field5

  28. 28

    Laravel - 用 table2 列更新 table1 列

  29. 29

    如何从 table1 中获取不在 table2 中的数据?代码点火器

热门标签

归档