• 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

    • UK planning measures to stop illegal content from going viral by Usama Jawad Image via Pixabay A few days ago, we learned that the UK's digital regulator Ofcom has mandated adult websites like Pornhub to put robust age check mechanisms in place to ensure that age-inappropriate content like pornography is not readily available to minors. Now, the government-approved authority has set its sights on a new target. According to an announcement on its website, Ofcom is now holding a consultation period for a set of measures it is proposing to curb the spread of illegal content online. These methods are a part of Ofcom's "Year of Action" initiative, where the regulator is taking decisive practical actions to ensure the online safety of the UK's citizens. Ofcom is proposing the implementation of better recommender systems and crisis response protocols to restrict illegal content from going viral online. In addition, it has also proposed the utilization of proactive mechanisms like hash checks for illegal images to nip the problem in the bud and not even allow any such visual content to be published online. Furthermore, the regulator will be asking tech firms and social media platform owners to leverage artificial intelligence systems in order to detect content like fraud and suicide. People who regularly engage in the practice of publication of illegal content online will also be punished with new sanctions. Lastly, Ofcom wants to build upon its existing child protection codes and capabilities online. It is planning to do this by placing restrictions on interactions between minors and streamers during livestreams. It will urge website owners to block users who share child sexual abuse material (CSAM) and is also proposing the development of AI tools to detect grooming activities and CSAM. The consultation period is open until 5pm on October 20, 2025. Ofcom is soliciting feedback from "service providers", law enforcement authorities, and the public until that deadline to finalize its proposal.
    • What are you talking about? I have had 4 Samsung fold devices and they all have the crease. It is not as noticable when facing straight on but its still noticable.
    • Well they would be right 90% of the time.
    • It didn't help but it certainly wasn't the cause.
  • Recent Achievements

    • Week One Done
      TIGOSS earned a badge
      Week One Done
    • First Post
      henryj earned a badge
      First Post
    • First Post
      CarolynHelen earned a badge
      First Post
    • Reacting Well
      henryj earned a badge
      Reacting Well
    • Community Regular
      Primey_ went up a rank
      Community Regular
  • Popular Contributors

    1. 1
      +primortal
      481
    2. 2
      +FloatingFatMan
      191
    3. 3
      ATLien_0
      162
    4. 4
      Xenon
      82
    5. 5
      Som
      76
  • Tell a friend

    Love Neowin? Tell a friend!