gpt4 book ai didi

Mysql查询喜欢数字大于x

转载 作者:太空宇宙 更新时间:2023-11-03 11:42:32 25 4
gpt4 key购买 nike

我有一个评论字段,用于存储网站上出售的商品的标题以及投标编号 (bid_id)。遗憾的是,bid_id 并未单独存储在该表中。

例如,我想查询编号(bid_id)大于 4,000 的商品。

所以,我所拥有的是:

select * from mysql_table_name where comment like '< 4000'

我知道这行不通,但我需要类似的东西。

非常感谢!

最佳答案

只需清理您的 bid_id 列。那么索引就是。

create table `prior`
( id int auto_increment primary key,
comments text not null
);
insert `prior` (comments) values ('asdfasdf adfas d d 93827363'),('mouse cat 12345678');
alter table `prior` add column bid_id int; -- add a nullable int column
select * from `prior`; -- bid_id is null atm btw
update `prior` set bid_id=right(comments,8); -- this will auto-cast to an int
select * from `prior`;
+----+-----------------------------+----------+
| id | comments | bid_id |
+----+-----------------------------+----------+
| 1 | asdfasdf adfas d d 93827363 | 93827363 |
| 2 | mouse cat 12345678 | 12345678 |
+----+-----------------------------+----------+

创建索引:

CREATE INDEX `idxBidId` ON `prior` (bid_id); -- or unique index

关于Mysql查询喜欢数字大于x,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40824640/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com