How do I combine these two SELECT query into one INSERT?Selecting a value from different tables in ORACLE?
I inserted a row into vehicle_unit by using INSERT this way:
INSERT INTO
vehicle_unit(vunit_id,vunit_purchase_price,vunit_exhibition_flag,vehicle_insurance_id,vunit_rego,
garage_code)
SELECT '3',50000.00, 'R', 'sports-ute-449-12b ',
'RD3000', garage_code
FROM garage
WHERE garage_email ='melbournec@rdbms.example.com ';
BUT now I do not want to manually enter sports-ute-449-12b. I want to select it from vehicle_detail table using the vehicle_title like this:
SELECT vehicle_insurance_id
FROM vehicle_detail
WHERE vehicle_title= 'Toyota Hilux SR Manual 4x2 MY14 '
But how do I select vehicle_insurance_id from vehicle_detail table AND select garage_code from garage table at the same time to insert into vehicle_unit table?
*The manufacturer_id is the same in both tables.
QO.
ANS:
You can use the multi-query function to execute multiple queries using the dot(.) operator
For Eg:
$sql=Select Vehicle_insurance_id....
$sql.=Select garage_code from garage_table
$sql.=Now Insert Query - Insert into vehincle_unit_table
if(mysqli_multi_query($databaseName,$sql))
{
echo "Successfully Done";
}
else{
echo "Problems in submitting";
}
----------------------------------------------------------------------------------------------------------------------------------------------------------------
THANKS!!
How do I combine these two SELECT query into one INSERT?Selecting a value from different tables...
How do I combine these 2 queries to produce something like
this
QUERY 1
SELECT hotel.country, time.year, time.month,
COUNT(booking.room_id) as booked
FROM booking
LEFT JOIN room on room.room_id = booking.room_id
LEFT JOIN hotel on room.hotel_id = hotel.hotel_id
LEFT JOIN time on booking.time_id = time.time_id
GROUP BY hotel.country, time.year, time.month
ORDER by hotel.country, time.year, time.month
QUERY 2
SELECT hotel.country, time.year, time.month,
COUNT(checkout.room_id) as checkedout
FROM checkout
LEFT JOIN room on room.room_id = checkout.room_id
LEFT JOIN hotel on room.hotel_id = hotel.hotel_id
LEFT...
How do I set a column attribute with value from another table? I have this manager_specialisation table: CREATE TABLE manager_specialisation ( specialisation_id NUMBER(4) NOT NULL, specialisation_type VARCHAR(50) NOT NULL ); And I want to update a column in my garage_manager table like this except the specialisation_id is WHERE specialisation_type = 'S'.? UPDATE garage_manager SET specialisation_id=manager_specialisation.specialisation_id WHERE man_id=1 AND garage_email= (SELECT garage_code FROM garage WHERE garage_email = 'melbournec@rdbms.example.com') ;
How come my query isn't running correctly?
It is meant to contain fields: PONumber, Account, orderDate,
itemNumber, and numberOrdered. Those come from the table OrderInfo.
It is meant to show all the information for orderDate
2/16/2012.
Query Tools Project 4 Part2 File Home CreateExternal Data Database Tools Help Design Tell me wh Insert Ro ① Union Pass-Through Show X Delete R View Run Select Make Append Update Crosstab Delete Table ビData Definition : e-Bul Table Results Query Type All Access...
I can’t figure out how to combine the results from one select statement with the results from another so that the results are side by side. Using Union causes the results of the second statement to add rows below the first results. The first select has sales_rep_id and number_of_customers. The second select has total_number_of_parts and total_customer_sales. I had to create ‘null as’ statements to create the proper columns in each of the statements so that the results from the second...
I am using Oracle SQL and am new to it. I have seven tables, one
of them is a subtable of two of the others. I need to do the
following queries:
1. List all Patients
and what Bed they are assigned to
2. List all patients
who had Treatments and what Treatment they received
3. List all patients
who had tests and what Test they had
4. List the employees
(doctors, nurses, etc.) who assisted each patient.
5. List...
This is done in visual basic langauge. I created a
query and i want to invoke this query from code.
for example, if i select the Company-owned radio button and hit the
display button ONLY the information for company owned stores should
be shown. same for the other radio button except it will only show
the information for the Franchise ownership.
F. for Franchises
C. for company owned
please provide the appropriate code.
and select statements.
hon Mcescft Vsal Studio...
Using mySQL, tables at the end... This assignment uses the tables from the vets database. The goal of the assignment is to get you to think about joins- inner join and outer joins. If you do a join, where you have the names of two or more tables in the From clause, then you must use the condition join syntax or the column name join. Take care that you do not accidentally do a Cartesian product. If your result set...
(Using Oracle SQL) How do I
find the primary key of this table? And then how do I consequently
drop the primary key from the table?
Edit: I was already give this code and it did not work
select constraint_name,constraint_type from user_constraint
where table_name='CUSTOMER';
Q7 (10 Points) Use ONE SQL statement to find out the name of the primary key constraint defined on Customer table. (Your SQL should return something like SYS_C0021715, numbers on your account may differ.) Then use...
You will develop an E-Commerce database used to maintain
customers, products and sales information. You are required to 1)
gather and analyze requirements 2) design logical structure of the
database 3) create stored procedures to develop the tables and
insert the data 4) write SQL statements for data extraction and
reporting.
Throughout the course of this semester you have analyzed the
requirements for an eCommerce database, designed and developed your
database. As a class we have gone through the process...
I need a response in your opinion, from this answer Q1. Any user accessing the database is more interested in quick and correct result than how a database is designed. Hence if we introduce redundancy in the table and if the performance of the query increases, then we can ignore 3NF. This is known as denormalization. In this process, a normalized table will be rejoined to have the redundancy in the table to increase the performance of the query. Denormalization...