반응형
mysql> DESC topic;
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| id | int | NO | PRI | NULL | auto_increment |
| title | varchar(100) | NO | | NULL | |
| description | text | YES | | NULL | |
| created | datetime | NO | | NULL | |
| author | varchar(30) | YES | | NULL | |
| profile | varchar(100) | YES | | NULL | |
+-------------+--------------+------+-----+---------+----------------+
6 rows in set (0.00 sec)
mysql> SELECT * FROM topic
-> ;
+----+------------+-------------------+---------------------+--------+---------------------------+
| id | title | description | created | author | profile |
+----+------------+-------------------+---------------------+--------+---------------------------+
| 1 | MySQL | MySQL is ... | 2021-10-13 19:58:34 | egoing | developer |
| 2 | ORCALE | ORCALE is ... | 2021-10-13 20:13:20 | egoing | developer |
| 3 | SQL Server | SQL Server is ... | 2021-10-13 20:13:28 | duru | database administrator |
| 4 | PostgreSQL | PostgreSQL is ... | 2021-10-13 20:13:35 | taeho | data sicentist, developer |
| 5 | MongoDB | MongoDB is ... | 2021-10-13 20:13:40 | egoing | developer |
+----+------------+-------------------+---------------------+--------+---------------------------+
5 rows in set (0.00 sec)
mysql> SELECT id FROM topic
-> ;
+----+
| id |
+----+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
+----+
5 rows in set (0.00 sec)
mysql> SELECT description FROM topic;
+-------------------+
| description |
+-------------------+
| MySQL is ... |
| ORCALE is ... |
| SQL Server is ... |
| PostgreSQL is ... |
| MongoDB is ... |
+-------------------+
5 rows in set (0.00 sec)
mysql> DESC topic;
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| id | int | NO | PRI | NULL | auto_increment |
| title | varchar(100) | NO | | NULL | |
| description | text | YES | | NULL | |
| created | datetime | NO | | NULL | |
| author | varchar(30) | YES | | NULL | |
| profile | varchar(100) | YES | | NULL | |
+-------------+--------------+------+-----+---------+----------------+
6 rows in set (0.00 sec)
mysql> SELECT "egong";
+-------+
| egong |
+-------+
| egong |
+-------+
1 row in set (0.00 sec)
mysql> SELECT "egoing",1+1
-> ;
+--------+-----+
| egoing | 1+1 |
+--------+-----+
| egoing | 2 |
+--------+-----+
1 row in set (0.00 sec)
mysql> SELECT *;
ERROR 1096 (HY000): No tables used
mysql> SELECT * FROM topic;
+----+------------+-------------------+---------------------+--------+---------------------------+
| id | title | description | created | author | profile |
+----+------------+-------------------+---------------------+--------+---------------------------+
| 1 | MySQL | MySQL is ... | 2021-10-13 19:58:34 | egoing | developer |
| 2 | ORCALE | ORCALE is ... | 2021-10-13 20:13:20 | egoing | developer |
| 3 | SQL Server | SQL Server is ... | 2021-10-13 20:13:28 | duru | database administrator |
| 4 | PostgreSQL | PostgreSQL is ... | 2021-10-13 20:13:35 | taeho | data sicentist, developer |
| 5 | MongoDB | MongoDB is ... | 2021-10-13 20:13:40 | egoing | developer |
+----+------------+-------------------+---------------------+--------+---------------------------+
5 rows in set (0.00 sec)
mysql> SELECT "egoing";
+--------+
| egoing |
+--------+
| egoing |
+--------+
1 row in set (0.00 sec)
mysql> SELECT "egoing",1+1;
+--------+-----+
| egoing | 1+1 |
+--------+-----+
| egoing | 2 |
+--------+-----+
1 row in set (0.00 sec)
mysql> SELECT id,title,description,created,author FROM topic WHERE author='egoing';
+----+---------+----------------+---------------------+--------+
| id | title | description | created | author |
+----+---------+----------------+---------------------+--------+
| 1 | MySQL | MySQL is ... | 2021-10-13 19:58:34 | egoing |
| 2 | ORCALE | ORCALE is ... | 2021-10-13 20:13:20 | egoing |
| 5 | MongoDB | MongoDB is ... | 2021-10-13 20:13:40 | egoing |
+----+---------+----------------+---------------------+--------+
3 rows in set (0.00 sec)
mysql> SELECT "egoing",4;
+--------+---+
| egoing | 4 |
+--------+---+
| egoing | 4 |
+--------+---+
1 row in set (0.00 sec)
mysql> SELECT "egoing",5*5;
+--------+-----+
| egoing | 5*5 |
+--------+-----+
| egoing | 25 |
+--------+-----+
1 row in set (0.00 sec)
mysql> SELECT "duru",2+1;
+------+-----+
| duru | 2+1 |
+------+-----+
| duru | 3 |
+------+-----+
1 row in set (0.00 sec)
mysql> SELECT * FROM topic;
+----+------------+-------------------+---------------------+--------+---------------------------+
| id | title | description | created | author | profile |
+----+------------+-------------------+---------------------+--------+---------------------------+
| 1 | MySQL | MySQL is ... | 2021-10-13 19:58:34 | egoing | developer |
| 2 | ORCALE | ORCALE is ... | 2021-10-13 20:13:20 | egoing | developer |
| 3 | SQL Server | SQL Server is ... | 2021-10-13 20:13:28 | duru | database administrator |
| 4 | PostgreSQL | PostgreSQL is ... | 2021-10-13 20:13:35 | taeho | data sicentist, developer |
| 5 | MongoDB | MongoDB is ... | 2021-10-13 20:13:40 | egoing | developer |
+----+------------+-------------------+---------------------+--------+---------------------------+
5 rows in set (0.00 sec)
mysql> SELECT "egoing",1+1
-> ;
+--------+-----+
| egoing | 1+1 |
+--------+-----+
| egoing | 2 |
+--------+-----+
1 row in set (0.00 sec)
mysql> SELECT 1+1;
+-----+
| 1+1 |
+-----+
| 2 |
+-----+
1 row in set (0.00 sec)
mysql> SELECT id,title,description,created,author FROM topic WHERE author='egoing' ORDER BY id DESC;
+----+---------+----------------+---------------------+--------+
| id | title | description | created | author |
+----+---------+----------------+---------------------+--------+
| 5 | MongoDB | MongoDB is ... | 2021-10-13 20:13:40 | egoing |
| 2 | ORCALE | ORCALE is ... | 2021-10-13 20:13:20 | egoing |
| 1 | MySQL | MySQL is ... | 2021-10-13 19:58:34 | egoing |
+----+---------+----------------+---------------------+--------+
3 rows in set (0.00 sec)
mysql> SELECT id,title,description,created,author FROM topic WHERE author='egoing' ORDER BY created DESC;
+----+---------+----------------+---------------------+--------+
| id | title | description | created | author |
+----+---------+----------------+---------------------+--------+
| 5 | MongoDB | MongoDB is ... | 2021-10-13 20:13:40 | egoing |
| 2 | ORCALE | ORCALE is ... | 2021-10-13 20:13:20 | egoing |
| 1 | MySQL | MySQL is ... | 2021-10-13 19:58:34 | egoing |
+----+---------+----------------+---------------------+--------+
3 rows in set (0.00 sec)
mysql> SELECT id,title,description,created,author FROM topic WHERE author='egoing' ORDER BY id DESC LIMIT 2;
+----+---------+----------------+---------------------+--------+
| id | title | description | created | author |
+----+---------+----------------+---------------------+--------+
| 5 | MongoDB | MongoDB is ... | 2021-10-13 20:13:40 | egoing |
| 2 | ORCALE | ORCALE is ... | 2021-10-13 20:13:20 | egoing |
+----+---------+----------------+---------------------+--------+
2 rows in set (0.00 sec)
mysql> SELECT id,title,description,created,author FROM topic WHERE author='egoing' ORDER BY id DESC LIMIT 2;
+----+---------+----------------+---------------------+--------+
| id | title | description | created | author |
+----+---------+----------------+---------------------+--------+
| 5 | MongoDB | MongoDB is ... | 2021-10-13 20:13:40 | egoing |
| 2 | ORCALE | ORCALE is ... | 2021-10-13 20:13:20 | egoing |
+----+---------+----------------+---------------------+--------+
2 rows in set (0.00 sec)
mysql> SELECT * FROM topic LIMIT 3;
+----+------------+-------------------+---------------------+--------+------------------------+
| id | title | description | created | author | profile |
+----+------------+-------------------+---------------------+--------+------------------------+
| 1 | MySQL | MySQL is ... | 2021-10-13 19:58:34 | egoing | developer |
| 2 | ORCALE | ORCALE is ... | 2021-10-13 20:13:20 | egoing | developer |
| 3 | SQL Server | SQL Server is ... | 2021-10-13 20:13:28 | duru | database administrator |
+----+------------+-------------------+---------------------+--------+------------------------+
3 rows in set (0.00 sec)
mysql>
mysql> SELECT "egoing",1+1
-> ;
+--------+-----+
| egoing | 1+1 |
+--------+-----+
| egoing | 2 |
+--------+-----+
1 row in set (0.00 sec)
#이 부분이 이해가 잘 안된다. 어째서 바로 아래행에 2가 나오는 것인지.
반응형
'생활코딩 > Dadabase - MySQL' 카테고리의 다른 글
IFNULL - NULL 값 변환 (0) | 2021.10.21 |
---|---|
DATABASE2 MySQL - 13.DELETE (0) | 2021.10.13 |
MySQL 테이블의 생성 - egoing (0) | 2021.10.13 |
DATABASE2 MySQL - 11.SELECT - egoing (0) | 2021.10.13 |
댓글