Database problem
@malihe please ask your problem her & my sister @lalaly will help you :)
*here
plz see the er diagram in file, i want to insert order of a customer which is first order a product, i related tables must change
Malihe can you please translate the problem my sister can't understand persian :D
i'll be back in 5 minutes, my laptop just needs a restart coz i just updated it .. so brb
okie :)
oh I get the problem :) she want to insert a record in table order which is related to other tables too so she dont know how to quirie that :)
Problem statement: she wants to place a new order but before inserting this order into the table she wants to insert the related information in the other relavent table
someone please help
Its my friends question & tomorrow is her exam
malihe i think it will go like this: INSERT INTO table_name (column1,column2,column3,...) VALUES (value1,value2,value3,...); first you will insert a new customer then you will make it sure that the product exist in product table then you place order details & in the end you'll place the order this is what I think dear
ewwww windows dba
you are missing a lot of information: order status, tracking, and delivery etc etc
man its not my work its my friend's @malihe work
@nincompoop can you help her :) kindly use easy english :)
I don't know how complex or simple you want your database to be. For generic purposes, first, have a goal in mind how the database should flow from an employee's/store perspective to entering information and then customer's perspective to receiving information there's the customer record basic demographic invoice record discounts returns cancellation payment record balance per order total balance in the account interaction or notes and alerts there are employees accessing or entering order information and there are also employees just receiving payments product records require inventories such as stocks, back-order every goods are either picked up or delivered, consider this also complexity increases depending on the store set-up
first things first, what database manager system are you using?
she is using mysql
i want to write the sql eqivalent code in java
mysql has an automation for a first record entry so long as you set up the order_id
hmm but nini she wants java code to insert the record
java will just pull the records from the server, it just displays them as a text so you needn't worry about that part you want to append or prepend? these are the two types of record insertion
i use this code to insert :statement.executeUpdate("INSERT INTO Employee VALUES (134, 'zohreh','amini','seller','144')")
insert into command
stmt.executeUpdate(sql); sql = "INSERT INTO ...
yes i know that
so what is the trouble you're running into?
i know how to insert in 1 table but as you see my question above and see the er diagram, i don't know how to write this query (insert order of a customer which is first orders a product)
nini she means she dont know how to write a nasted query that will insert a new order of a customer for a product that already exist :)
Malihe you will use a "nasted query" search this one on google
SELECT * FROM ( select (select A from B where ... ) as C from D ) subq WHERE C like ' ... '
i know this , but i don't see this use for insert anywhere
you can use it in the same way for insert
INSERT INTO Orders VALUES (.....) where custID ... smoething like this
INSERT INTO Staffs VALUES(....) WHERE EXISTS (SELECT * FROM Branch b WHERE s.branchNo = b.branchNo AND city = ‘London’ ); this is proper syntax
I found it :D
now can you try it for your tables ?
Join our real-time social learning platform and learn together with your friends!