How to apply media query in table?

Microsoft Access 2007, SQL Query - How to insert values from another table?

  • Would appreciate any help :) I have two tables in Access and I am trying to populate them. The first table is artist: name birth death nationality styles I have populated these fine. The next table is my paintings table: painting_id title media height width artist My SQL query at the moment is: INSERT INTO paintings VALUES ("P01", "The Opening of Waterloo Bridge", "Oil on canvas", 1308, 2180, SELECT name FROM artist WHERE name = "John Constable"; As you can see, all of the values apart from Artist will fit in as the name of the artist is from another table. Is there a way of adding it in? When creating the painting table I have added a reference to artist : artist VARCHAR(20) REFERENCES artist(name) Thanks in advance :)

  • Answer:

    Two ways to do this - INSERT INTO Paintings VALUES ( "P01", "The Opening of Waterloo Bridge", "Oil on canvas", 1308, 2180, ( SELECT name FROM artist WHERE name = "John Constable" ) ) OR INSERT INTO Paintings SELECT "P01", "The Opening of Waterloo Bridge", "Oil on canvas", 1308, 2180,name FROM artist WHERE name = "John Constable" -- In 'thoughts'... Lonely Rogue.

Aahmed at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

This seems to be a badly designed database. Surely the Artists table should have a unique ID field e.g. artist_ID? Additionally the Painting table should have the artist_id rather than the artist field?

ray_diator

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.