简体   繁体   English

SQL查询提取前几个字符

[英]SQL query extracting first few characters

So I have a column in my 'abc' table called 'phones' I need to select everything from the table but only for the people with '520' area codes and the the format for the phone numbers are like so : (540)333-4534 and (804)232-2222. 因此,我在“ abc”表中有一列称为“电话”,我需要从表中选择所有内容,但仅适用于具有“ 520”区号的人,电话号码的格式如下:(540)333 -4534和(804)232-2222。

I am completely new to SQL and this is over my head so any help would be awesome. 我对SQL完全陌生,这太麻烦了,所以任何帮助都很棒。

I have so far: 我到目前为止:

SELECT * 
FROM abc
WHERE phones?????????

Use a like statement with a wildcard: 使用带通配符的like语句:

SELECT * 
FROM abc
WHERE trim(phones) like '(520)%'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM