• 0

MYSQL INSERT JOIN?


Question

hello I want a simple way of writing this >>

insert into table
LEFT JOIN `otherTable`
on otherTable.`field`='value'
AND otherTable.`otherfield`='anotherValue'
(`column`, `column`, `column`)VALUES('data',otherTable.`data`,'anotherValue')

I know this does not work, but you can see the logic i am trying to achieve... but I was wondering if there is a simple way to do this..I know of many ways (selecting the data first, nested select statement and so forth) but while writing a new script I thought hmm there has to be an easier cleaner way to do this.... so I thought I would ask neowin for future reference

Link to comment
https://www.neowin.net/forum/topic/1233693-mysql-insert-join/
Share on other sites

2 answers to this question

Recommended Posts

  • 0
INSERT INTO table (`column`, `column`, `column`)
SELECT
'Data',
otherTable.`data`,
'anotherValue'
FROM otherTable
WHERE otherTable.`field` = 'value'
AND otherTable.`otherfield` = 'anotherValue'

Might not be 100% accurate, written in my head whilst lunching on a sandwich but should give you the gist of there you need to go ;)

  • 0
  On 21/10/2014 at 11:57, Kami- said:
INSERT INTO table (`column`, `column`, `column`)
SELECT
'Data',
otherTable.`data`,
'anotherValue'
FROM otherTable
WHERE otherTable.`field` = 'value'
AND otherTable.`otherfield` = 'anotherValue'

Might not be 100% accurate, written in my head whilst lunching on a sandwich but should give you the gist of there you need to go ;)

 

ahh ok thanks Il give that a look....i wasnt to far off the mark

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Nope. This will be disabled instantly on all my devices. But at least they're not forcing it upon users, it can be turned off.
    • But, but, Meta did not have address to your data? I don’t believe this cap. Why-o-why don’t I trust them?!
    • They're not lying in this case, violating your privacy and safety is certainly of utmost importance to Zuck and his creeps...
    • Microsoft employee behind AnduinOS releases more updates, here's how to upgrade by Paul Hill A small Linux distribution created by a Microsoft employee drew quite a bit of attention in recent months with its attempts to ease users into Linux by looking just like Windows. This week, AnduinOS was upgraded to a new batch of point releases, including 1.3.3, 1.2.6, and 1.1.6. These point releases do not bring too many changes, and all the changes that are introduced are identical across all three versions. Here are the release notes this time: Fixed an accessibility issue that caused the screen reader unable to read the text. Added librime-plugin-lua for ibus-rime users to support Lua scripts. This only affects zh_CN by default. Added policykit-desktop-privileges to the default app list to allow no-password prompts for mount, simple updates, etc. As a new Linux distribution on the scene, updating it is not as straightforward as opening a software store and tapping the upgrade button. For now, upgrades rely on a script. To update your computer using this script, open up a terminal window and type do_anduinos_upgrade. Running this command will bring you up to the latest point release for your respective major version, even if you’re not on the latest point release right now. In the future, Anduin Xue, the Microsoft employee who develops AnduinOS, wants to allow you to grab new versions via sudo apt upgrade. For the time being, users will need to stick to running the script to ensure their device is up to date. Last month, it was announced that AnduinOS 1.4 will be based on Ubuntu 25.10 and will drop in late October, while Anduin OS 1.5 will be based on Ubuntu 26.04 LTS and arrive in late April 2026. Hopefully, we will see more maturation with those updates, such as upgrading the system with an apt command instead of a script.
    • I know companies like to assume first party ads are okay, and I often don't have a huge problem with things like extra iCloud space offers showing up in relevant places. Relevant being the keyword. There is literally nowhere on a phone where a movie ad would ever be in context.
  • Recent Achievements

    • First Post
      solidox earned a badge
      First Post
    • First Post
      BA the Curmudgeon earned a badge
      First Post
    • One Year In
      blissa jayden earned a badge
      One Year In
    • One Month Later
      blissa jayden earned a badge
      One Month Later
    • Week One Done
      blissa jayden earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      561
    2. 2
      ATLien_0
      213
    3. 3
      +FloatingFatMan
      171
    4. 4
      Michael Scrip
      152
    5. 5
      Som
      151
  • Tell a friend

    Love Neowin? Tell a friend!