- create a database "MyDatabase"
- create a table "MyTable", with 4 fields[id, name, password,dateCreated]
- delete data from "MyTable" which have name begin with 'A'
- insert 3 rows of data with this information:
- name:Ali, Johan, Frankie; password: ali123, johan123, frankie123
- update data from "MyTable", change the name to "Ali Adam", "Johan Harry", "Frankie Tom"
- empty the table / delete all data from "MyTable"
- Sort "MyTable" in descending order according to "name" field
- add a new field "age" to "MyTable"
- remove "MyTable" from "MyDatabase"
- u have 2 tables user(id, name, password), and activity(id, userid, activityName)
join these 2 table and show the data of user's name and his activity.
QUESTION 3
ReplyDeleteDELETE FROM MyTable
WHERE name like 'A%'
1. Create database mydatabase;
ReplyDeleteThis comment has been removed by the author.
ReplyDeletecreate table mytable(
ReplyDeleteid int(10)not null;
name varchar(40) not null;
password varchar(40) not null;
dateCreated varchar (40) not null;
)
Question 2
Deletecreate table mytable(
Deleteid int(10)not null;
name varchar(40) not null;
password varchar(40) not null;
dateCreated varchar (40) not null;
Primary key(id);
)
delete from mytable
ReplyDeletequestion no 6
Deletequestion 9
ReplyDeleteDrop table MyTable
Quation num 7:
ReplyDeleteSELECT * From MyTable
Order by name desc
Question 8
ReplyDeleteALTER TABLE MyTable
ADD age int(5);
QUESTION 10
ReplyDeleteSELECT user.name, activity.activityName
FROM user JOIN activity ON
user.ID = activity.userID
QUESTION 4 (Vimala)
ReplyDeleteINSERT INTO mytable
(name, password)
VALUES ('Ali','Ali123')
('Johan','Johan123')
('Frankie','Frankie123');
Q6:
ReplyDeleteTRUNCATE TABLE MyTable;
This comment has been removed by a blog administrator.
ReplyDeletesudah update
ReplyDeleteREPLACE INTO MyTable
SET name = 'Ali Adam'
WHERE name ='Ali'
REPLACE INTO MyTable
SET name'Johan Harry'
WHERE name ='Johan'
REPLACE INTO MyTable
SET name ='Frankie Tom'
WHERE name ='Frankie'
This comment has been removed by the author.
Deletemay be u need the semi-colon(;) in each replacements?
ReplyDeleteAnother approach would be using UPDATE...SET...WHERE