hussein hussein - 1 year ago 102
MySQL Question

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?

Answer Source

Well, you are creating a view. This command does not return any rows. It simply creates a view you can later use in your queries. Now you have to query the view like below, to see what it outputs:

select * from matchresults_view
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download