Jump to content

Select inside an insert that returns a number?


onedumbcoder

Recommended Posts

is it possible to have a select inside of a insert that will return a numbeR?

 

for example I have lets say a table called animal with the following data

 

id  type

1    cow

2    bird

3    fox

4    cow

 

 

can i do something like this

 

INSERT INTO barn(animal, count)  VALUES('cow', (SELECT COUNT(id) FROM animal WHERE type='cow'))

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.