🔒 Closed Tanong --sa sql

Status
Not open for further replies.

Racer_X

Eternal Poster
select * from bcs_20 where com_code=(substr(com_code, 1,3)=911

gusto ko po select lahat ng com_code na my number na '911' po

bali po 12 digits po yung com_code kaya ni-substr ko po muna sya ..

kaso po ayaw gumana ..

pano po kayo tamang code. .baguhan lang po kasi .

salamat po
 
Try mo INSTR
SQL:
select * from bcs_20 where INSTR(com_code,"911") > 0

PS:

Try mo rin ito kung gagana:
SQL:
select * from bcs_20 where (substr(com_code, 1,3)='911'
 
Cge po salamat po..
Try mo INSTR
SQL:
select * from bcs_20 where INSTR(com_code,"911") > 0

PS:

Try mo rin ito kung gagana:
SQL:
select * from bcs_20 where (substr(com_code, 1,3)='911'
try ku po talaga..
Balikan ku po kau
 
Try mo INSTR
SQL:
select * from bcs_20 where INSTR(com_code,"911") > 0

PS:

Try mo rin ito kung gagana:
SQL:
select * from bcs_20 where (substr(com_code, 1,3)='911'
wala po gumana lahat

bali po ung com_code pokasi mahaba.. need ko po i-subtr para po makuha ko lang yung 1-3 digits po..

ngaun po gusto ko lang po mapalabas yung lahat ng '911' lang po .. pasensya na po .. baguha lang po ako .. learning by my self lang po ..

salamat po
 

Attachments

  • 241390270_721192645532749_23890862103240141_n.webp
    241390270_721192645532749_23890862103240141_n.webp
    148.7 KB · Views: 14
ang gusto yata ni ts eh extraction by pattern at hindi extraction by index or range.

try mo to:
Code:
dvdrental=# select actor_id, first_name, last_name from actor where substring(last_name, 'cet') = 'cet';                                       
 actor_id | first_name | last_name 
----------+------------+-----------
       19 | Bob        | Fawcett
      199 | Julia      | Fawcett
(2 rows)

dvdrental=# select substring(last_name, 'cet') as mystring from actor where substring(last_name, 'cet') = 'cet';                                
 mystring 
----------
 cet
 cet
(2 rows)
 
Gumagana naman, hindi mo lang alam gamitin o hindi mo ma-explain ng mabuti yung gusto mong mangyari.
View attachment 1760077
yung comcode po kasi 12 digits po sya .. ngayon need ko kuning lang po yung first 3 digits, tapos select all yung mga first 3 digits lang na '911'.. ndi po sya plain '911' lang po . . kasali po sya sa comcode na 12 digits "911930429349"
454934002234
239405495832

kaya po need "substr" .. para ma separate yung first 3 digits lang po ..
 
Gamitin mo yung SUBSTR para makuha mo yung 1st 3 characters. Puwede mo pa rin naman magamit yung INSTR para macheck yung first 3 digits, palitan mo lang yung condition:

SQL:
select * from bcs_20 where INSTR(com_code,'911') = 1

Ibig sabihin niyan ay nasa unahan ng column yung '911'.

EDIT: MySQL ba ito?
 
Gamitin mo yung SUBSTR para makuha mo yung 1st 3 characters. Puwede mo pa rin naman magamit yung INSTR para macheck yung first 3 digits, palitan mo lang yung condition:

SQL:
select * from bcs_20 where INSTR(com_code,'911') = 1

Ibig sabihin niyan ay nasa unahan ng column yung '911'.

EDIT: MySQL ba ito?
meju may naiisip po ako sa sinabi nyu po .. salamat po . . sql po sya yung sa pgadmin .. baguhan lang po . .aralin ko po yang INSTR
 
Status
Not open for further replies.

Similar threads

About this Thread

  • 13
    Replies
  • 773
    Views
  • 6
    Participants
Last reply from:
vespine

Trending Topics

Online now

Members online
409
Guests online
1,280
Total visitors
1,689

Forum statistics

Threads
2,274,140
Posts
28,953,851
Members
1,235,099
Latest member
hiro1985
Back
Top