• 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

    • Been using Linux for the last 15-16 years, and I don't agree to any of this.. Come on, guys..
    • Crucial 8TB X10 2100 MB/s USB-C (3.2) external SSD is priced lowest ever at just $440 by Sayan Sen External SSDs are great as their portability makes them quite convenient. If you are shopping for one, then Micron has a deal that may just be right for you. The company's Crucial X10 external SSDs are currently on sale for their lowest ever prices (purchase links down below). What is interesting about the Pro X9 and X10 models is that they are based on TLC or triple-level cell NAND compared to QLC or quad-level on the X6 and X8 external SSDs, making them higher endurance and better for longer sustained reads and writes. Unfortunately, Crucial does not specifically state the kind of NAND flash the X10 has, though, from its three-year warranty, as opposed to five years on the Pro models, it can be said that the drive is QLC. As such it is not the ideal drive for constant data reads and writes, but you can certainly use it fairly often. Speaking of reads and writes, Crucial promises up to 2100 MB/s sequential reads. To enable such speeds, the SSD supports USB 3.2 Gen-2 2x2 interface and comes with a Type-C to Type-C USB cable in the box. But it is also backward compatible with USB 3.2 Gen 2/USB 3.2 Gen1/USB 3.1 Gen1/ USB 3.0 (5Gb/s), so this would mean lower speeds. In terms of durability, the X10 Pro and X9 Pro pack IP65 water and dust resistance, and the firm claims that the drive's drop-proof durability is up to 9.8 feet or about 3 meters. Get the Crucial X10 at the link below: Crucial X10 8TB Portable SSD, Up to 2,100MB/s, USB 3.2 USB-C, Compatible with Windows, Mac & Android, Blue - CT8000X10SSD9-02: $439.99 (Amazon US first-party seller) This Amazon deal is US-specific and not available in other regions unless specified. If you don't like it or want to look at more options, check out the Amazon US deals page here. Get Prime (SNAP), Prime Video, Audible Plus or Kindle / Music Unlimited. Free for 30 days. As an Amazon Associate, we earn from qualifying purchases.
  • Recent Achievements

    • Conversation Starter
      johnwin1 earned a badge
      Conversation Starter
    • One Month Later
      Marwin earned a badge
      One Month Later
    • One Year In
      fred8615 earned a badge
      One Year In
    • Week One Done
      Jim Dugan earned a badge
      Week One Done
    • Week One Done
      Adam Todd earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      215
    2. 2
      snowy owl
      156
    3. 3
      ATLien_0
      134
    4. 4
      Xenon
      127
    5. 5
      +FloatingFatMan
      117
  • Tell a friend

    Love Neowin? Tell a friend!