PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, January 25, 2022

[FIXED] MYSQL Query to INSERT INTO a value into one row and copy data from another table into another row

 January 25, 2022     mysql, phpmyadmin     No comments   

Issue

I need something like this

INSERT INTO `tb1`(`button`,'name')
SELECT button FROM `tb2` WHERE `ID` = 1, VALUE ('some name')

In button I want to copy button data from tb2, In name I just want to put in a name. I can either copy from another table or enter a VALUE but I cannot do both.

Any suggestions would be appreciated.


Solution

Try this:

INSERT INTO `tb1`(`button`,`name`)
SELECT button, 'Some name' FROM `tb2` WHERE `ID` = 1


Answered By - Gurwinder Singh
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing