回覆列表
  • 1 # lanfengz3

    select *

    from table1

    where

    `text` like CONCAT( "%" , (select name from table2 where id =3), "%" );

    這樣看看, 行麼?

    CONCAT 是 mysql 中函式, 用於連線字串的。

    CREATE TABLE table1 (

    `text` varchar(10)

    );

    CREATE TABLE table2 (

    id int,

    name varchar(10)

    );

    INSERT INTO table1 VALUES ("我愛家");

    INSERT INTO table2 VALUES (3, "愛");

    select *

    from table1

    where

    `text` like CONCAT("%", (select name from table2 where id =3), "%" );

    +--------+

    | text |

    +--------+

    | 我愛家 |

    +--------+

    1 row in set (0.00 sec)

  • 中秋節和大豐收的關聯?
  • Burn that bridge中文歌詞?