-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathPandaMartDB.sql
78 lines (65 loc) · 1.92 KB
/
PandaMartDB.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
use Mustafa;
Create Table items_tb1(
item_id int primary key identity(1,1),
item_name varchar(50),
item_price int,
item_discount int,
);
select*from items_tb1;
insert into items_tb1 values ('Lipton Tea Lagr e',350,20), ('Lipton Tea Small',250,10), ('EveryDay Lagre',1350,50), ('EveryDay Small',1000,20);
insert into items_tb1 values ('Lays',50,5);
CREATE TABLE login(
id int primary key identity(1,1),
username varchar(50),
password varchar(50)
);
insert into login values ('Mustafa','Mus@123');
select * from login;
CREATE table signup(
user_id int primary key identity(1,1),
fname varchar(50),
lname varchar(50),
age int,
gender varchar(50),
address varchar(60),
email varchar(50),
Password varchar(50)
);
select * from signup
create table order_master(
invoice_id int primary key identity(1,1),
username varchar(40),
datetime varchar(50),
finalcost int
);
insert into signup values ('Salman', 'Khan', 32, 'Male', 'India', '[email protected]', 'Salman32@');
select * from order_master
create table order_details(
order_details_id int primary key identity,
innvoice_id int foreign key references order_master(invoice_id),
items_name varchar(50),
unit_rice int,
discount_per_item int,
quantity int,
subtotal int,
tax int,
totalcost int
);
select * from order_details
create procedure sp_getBothTableData
as
begin
select A.invoice_id, A.username, A.[datetime], B.items_name, B.unit_rice, B.discount_per_item, B.quantity, B.subtotal, B.tax, B.totalcost, A.finalCost
from order_master as A
inner join order_details as B
on A.invoice_id = B.innvoice_id;
end
create procedure sp_getBothTableDataByInvoice
@invoiceID int
as
begin
select A.invoice_id, A.username, A.[datetime], B.items_name, B.unit_rice, B.discount_per_item, B.quantity, B.subtotal, B.tax, B.totalcost, A.finalCost
from order_master as A
inner join order_details as B
on A.invoice_id = B.innvoice_id where A.invoice_id = @invoiceID
end