Get the App
SLTechnology News&Howtos  ›  Database  › 

Wildcards in 2011-10-28 LIKE conditions

Shulou Source: shulou.com Published: 2022-06-01 05:48:30 09月27日 Update

Http://www.itpub.net/thread-1499223-10-1.html

93rd floor

I created this table and filled in the data:

CREATE TABLE plch_new_parts (partnum NUMBER, partname VARCHAR2 (50)) / BEGIN INSERT INTO plch_new_parts (partnum, partname) VALUES (1,'MY PART NUMBER 1'); INSERT INTO plch_new_parts (partnum, partname) VALUES (2, 'MY_PART_NUMBER_2'); INSERT INTO plch_new_parts (partnum, partname) VALUES (3,' MY_PART NUMBER_3'); COMMIT;END;/

What will appear on the screen when I execute the following code?

DECLARE l_counts DBMS_SQL.number_table;BEGIN l_counts (1): = 0; l_counts (2): = 0; l_counts (3): = 0; l_counts (4): = 0 FOR rec IN (SELECT partname FROM plch_new_parts ORDER BY partnum) LOOP IF rec.partname LIKE'MY PART NUMBER% 'THEN l_counts (1): = l_counts (1) + 1; END IF; IF rec.partname LIKE' MY_PART_NUMBER_%' THEN l_counts (2): = l_counts (2) + 1; END IF IF rec.partname LIKE 'MY_PART NUMBER_%' THEN l_counts (3): = l_counts (3) + 1; END IF; IF rec.partname LIKE' MY?PART?NUMBER?*' THEN l_counts (4): = l_counts (4) + 1; END IF; END LOOP; FOR indx IN 1. L_counts.COUNT LOOP DBMS_OUTPUT.put_line (l_counts (indx)); END LOOP;END;/

(A)

1110

(B)

1320

(C)

0 0 0 3

(D)

3333

(E)

1323

The running result is as follows

SQL > DECLARE 2 l_counts DBMS_SQL.number_table; 3 4 BEGIN 5 l_counts (1): = 0; 6 l_counts (2): = 0; 7 l_counts (3): = 0; 8 l_counts (4): = 0 9 10 FOR rec IN (SELECT partname 11 FROM plch_new_parts 12 ORDER BY partnum) 13 LOOP 14 IF rec.partname LIKE'MY PART NUMBER%'15 THEN 16 l_counts (1): = l_counts (1) + 1; 17 END IF 18 19 IF rec.partname LIKE 'MY_PART_NUMBER_%' 20 THEN 21 l_counts (2): = l_counts (2) + 1; 22 END IF; 23 24 IF rec.partname LIKE' MY_PART NUMBER_%' 25 THEN 26 l_counts (3): = l_counts (3) + 1; 27 END IF 28 29 IF rec.partname LIKE 'MY?PART?NUMBER?*' 30 THEN 31 l_counts (4): = l_counts (4) + 1; 32 END IF; 33 END LOOP; 34 35 FOR indx IN 1. L_counts.COUNT 36 LOOP 37 DBMS_OUTPUT.put_line (l_counts (indx)); 38 END LOOP; 39 END; 40 / 132PL/SQL procedure successfully completedSQL >

Answer B

The answer is on the 96th floor

2011-10-28 answer B. _ matches a single character,% matches any character, * and? It's a lie.

Tags: Answers characters codes singles screens data results runs conditions wildcards Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei macOS MariaDB NVidia Apple