hussein
hussein

Reputation: 29

Create view statement returns an empty result set

I have a table called matchresults which has five columns named mresultid, playerid, seasonmatchid, rank, ratingsearned

mresultid is the primary key and playerid and seasonmatchid are foreign keys

The problem is that when I try to create a view on this table:

DROP VIEW IF EXISTS matchresults_view;
CREATE  VIEW matchresults_view AS 
select mresultid, playerid, seasonmatchid 
from matchresults
where id = 8 ;

The query runs but it says mysql returned an empty result set. This is not true as I should be having two tuples in the result set.

What is wrong with the query?

Upvotes: 1

Views: 1719

Answers (1)

Kamil Gosciminski
Kamil Gosciminski

Reputation: 17157

Well, you are creating a view. This command does not return any rows. It simply creates a view which you can think of as SQL query saved under a name, so that it is later possible to use in your queries. It will still execute the underlying SQL statement.

Now you have to query the view like below, to see what it outputs:

select * from matchresults_view

Upvotes: 1

Related Questions