logo
Tags down

shadow

Insert data in table using two or more tables


By : Will Hurst
Date : September 22 2020, 01:00 PM
I wish did fix the issue. INSERT...SELECT syntax is what you're looking for (instead of INSERT...VALUES, which is limited to single values per column in each value list). That allows you to select the data directly from the table(s) concerned, using normal SELECT and JOIN syntax. You can also hard-code values which you want to appear on every row, just as you can in a normal SELECT statement. Basically, write the SELECT statement, get it to output what you want. Then stick an INSERT at the start of it and it sends the output to the desired table.
code :
insert into insight_owner (column_one, column_two, column_three, column_four, column_five)
select '1', '0', NULL, (select u.id from users u where u.sid='test1'), i.id
from insights i


Share : facebook icon twitter icon

INSERT into a table using data from 2 other tables


By : shahana Masthan
Date : March 29 2020, 07:55 AM
wish help you to fix your issue First the number of attributes to INSERT should be matching with the number of attributes of SELECT.
Second, you don't need the last values line
code :
INSERT INTO enduserdevicemap (fkenduser,fkdevice,defaultprofile,tkuserassociation) 
SELECT e.fkenduser,e.fkdevice,d.defaultprofile,d.tkuserassociation
FROM enduser e,device d 
WHERE enduser.userid = 1001 AND device.name like '%6%' 

Insert data into 2 tables using first table ID


By : mirage
Date : March 29 2020, 07:55 AM
wish help you to fix your issue I've two tables in my joomla 2.5 site component that trying to inset two tables and first table ID should be second table foreign-key. , Try This,
In Joomla you can get the last insert id using
code :
 $db->insertid();
    $db = JFactory::getDbo();
    $query = $db->getQuery(true);

     // Insert columns.
     $columns = array('mytab_name', 'mytab_country', 'mytab_city');
     // Insert values.
     $values = array($db->quote($mytab_name), $db->quote($mytab_country), $db->quote($mytab_city));

    // Prepare the insert query.
    $query
         ->insert($db->quoteName('#__mytable'))
         ->columns($db->quoteName($columns))
         ->values(implode(',', $values));

    // Set the query using our newly populated query object and execute it.
    $db->setQuery($query);
    $db->query();

How to insert data from two tables into one table


By : jack
Date : March 29 2020, 07:55 AM
like below fixes the issue I need to insert values from two tables into one table. Eg Table 1 is outward and table 2 is product table. I need to insert values into outward table and from product table i have productname which needs to be inserted into outward table. My code is , There is the basic:
code :
INSERT INTO tbltrn_outward(chalanno, godownsrno, ... )
SELECT
   column1
   , column2
   , ...
FROM tbltrn_product

Insert multiple data into two tables and need to insert the last inserted id into another table


By : Youvraj
Date : March 29 2020, 07:55 AM
wish helps you For the latest problem you posted. You are calling obj.test method only once after all the if blocks.
So the "course" variable will have value from the latest if block where the condition is true.
code :
string course = "";
string Name = schName.Text;
scholarshipBLL obj = new scholarshipBLL();

List<addScholarship> addScholarshipList= new List<addScholarship>();

addScholarship scholarship;
if (DIT.Checked )
{
    scholarship = new addScholarship(Name,course);
    addScholarshipList.Add(insertedName);
    course = "DIT";
    DataTable dt = obj.test(Name, course);

}

if (DFI.Checked)
{
    scholarship = new addScholarship(Name,course);
    addScholarshipList.Add(insertedName);
    course = "DFI";
    DataTable dt = obj.test(Name, course);

}

Insert data in a table from two other tables


By : AndreasTS
Date : March 29 2020, 07:55 AM
This might help you Try to remove ; at the end of your sql and remove FULL due to MySQL do not support FULL JOIN
code :
  string MergeTables = string.Format(@"INSERT INTO exercices (AF,region) 
  SELECT e1.AF, e2.region FROM bilan e1 
    JOIN data e2 ON e1.siren = e2.siren
   ");
Related Posts Related Posts :
  • Access denied error while connecting to MySQL in App in Azure App Service
  • My POST request is working with Node.js but not with API
  • I am creating a database for a community to store details of all the members. What would be the best way to create such
  • Select between range of values in 2 tables
  • What's the Best way to select the min value from several columns and then calculate their sum?
  • MYSQL: AND statement causing expected results to not display
  • mysql - Select where image_url=0 but return all rows?
  • Create function that returns a "SELECT" statement result
  • Subquery returns more rows
  • Unrecognized Keyword and Statement Type (FROM)
  • Optimise mysql query with group by
  • FOREIGN KEY ON DELETE SET NULL
  • Avoid duplicate data in mySQL table
  • Why is SQL Count(*) returning 1 from an empty table?
  • Symfony 4 - How to dynamically add field in an entity?
  • Pivot table for single table in Laravel
  • MySQL inconsistently altering name of indexes associated with foreign keys on InnoDB tables
  • SQL: Alternative to COALESCE() function that groups all values into one column
  • SUM from different column and from different table and show result in one row of each year
  • MySQL query too much slow
  • How to count quantity of duplicate data?
  • Find the number of unique users who have visited at least two different countries per site
  • Restarting Mysql Database in Cpanel on a shared Server
  • Can we create sql DB server backup on different database(free database)?
  • Convert time into range in SQL
  • MariaDB 10.3 implicit cast of string parameter to integer column fails
  • UNION ALL and SELECT
  • How to access redmine log folder inside a docker after a docker-compose?
  • mysql json where clause
  • What is causing the error "Column does not match the value count at row 1"?
  • MySQL Return JSON array index based on property value
  • Finding users with at least one of every item
  • Multi-event tournament standings
  • MySQL delete duplicate records but keep more than one (ex. 5)
  • Display the users that have not yet created projects this month in specific city (count=0)
  • Have a Syntax problem related to an event which I cannot find
  • How can I get all the devices from database table whose RAM is in between 1 MB to 2 GB?
  • Slow query for join tables
  • RDS Upgrade Fails despite prepatchcompatibility showing no errors
  • MySQL query really slow as loading benchmark
  • How to improve query speed in mysql query
  • Count values of MySQL
  • How to copy values from one table to other table with some additional data
  • Why my WHERE and COUNT clause do not work?
  • How to update SQL on JOIN
  • MySQL: Use select in update query
  • Selecting rows that are within 2 hours from current time
  • SQL Query Including Joins
  • How does one update MySQL database periodically separate from website
  • How data backup is handled in production via Docker
  • Sphinxsearch: 1064 can not use HAVING with attribute not related to GROUP BY
  • MySQL root password reset -bash: syntax error near unexpected token `('
  • Laravel where query for getting record if the difference of two fields is not 0
  • Group or eliminate duplicates fields in columns
  • How to get latest data inserted in mySQL?
  • How to reduce select * from table_name query execution time for table with 200k+ records?
  • How to only add specific value to a column?
  • How does an incoming request to a nodejs server get handled when the event loop is waiting for a DB operation
  • SQL query to get count of unique combinations in the table - MySql
  • Can I speed up this VBA function that queries an (AWS) mysql db?
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk