Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do i show values from the table

how do i show all values from this table

 +------+---------+-------+--------+-----+
 | A    | B       | C     | D      | E   |
 +------+---------+-------+--------+-----+
 |   2  |    K    | M     | NULL   | S   |
 |   3  |    L    | C     | NULL   | N   |
 |   4  |    R    | P     | NULL   | N   |
 |   5  |    P    | N     | C      | N   |
 |   6  |    Y    | Q     | NULL   | S   |
 |   7  |    S    | T     | NULL   | S   |
 |   8  |    C    | M     | NULL   | N   |
 |   9  |    X    | C     | NULL   | S   |
 |  10  |    E    | Q     | NULL   | N   |
 |  11  |    A    | C     | NULL   | S   |
 |  12  |    C    | NULL  | C      | N   |
 |  13  |    F    | Q     | NULL   | N   |
 |  14  |    L    | NULL  | C      | S   |
 |  15  |    S    | P     | NULL   | S   |
 +------+---------+-------+--------+-----+

to this.
show the first 8 values from column A, B and the 7 will be 5 in column A

SELECT A, B FROM letters LIMIT 8;

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

 
 +------+--------+
 | A    | B      |
 +------+--------+
 |   2  |    K   |
 |   3  |    L   |
 |   4  |    R   |
 |   5  |    P   |
 |   6  |    Y   |
 |   5  |    S   |
 |   8  |    C   |
 |   9  |    X   |
 +------+--------+
 

>Solution :

You’ll want to use a case expression or the if() function. My preference is a case expression because it’s more portable. Furthermore you’ll need to supply an ORDER BY clause since records in a table have no ordering.

SELECT CASE WHEN A=7 THEN 5 ELSE A END as A, B FROM letters ORDER BY letters.A LIMIT 8;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading