I have a query that asks me
Create a query that displays for a given athlete the events they have participated in. For each test, the date, the description of the competition, the result stored in 'result' of Score, as well as the name of the stadium (venue) in which the test was carried out, must be shown. Show the SQL query. Make this filter the data to show only the data of the user whose nick is 'eisaza':
I have the query done but I don't understand how to put the value of the field score.score
in score.result
.
And my query is this;
select score.dateresult,competition.compdescription,score.score,venue.venue
from score,competition,venue,webclient,athlete
where athlete.idathlete = score.idathlete
and score.idcompetition = competition.idcompetition
and competition.idvenue = venue.idvenue
and athlete.idathlete = webclient.idwebclient
and webclient.nick ='eisaza';
That said, I want to get into the field result
of score
himscore
score
All the best!!
The query you have is quite good, you just have to include
result
the table fieldscore
. That is, you don't have to put anything in the fieldresult
,score
just don't includescore.score
and instead includescore.result
.Based on your query, it would look like this:
That being said, you are writing the query in a very old style , doing what is known as
join
implicit. This is how they used to be written before 1992 (yes, 1992 ).The SQL 92 standard, which is now supported by all engines, introduced the
join
explicit syntax, which simplifies the way queries are written and makes them easier to understand and maintain.In this, the conditions that relate the tables are basically separated from the conditions that filter the results of the query. The conditions that relate the tables are written as the clause is written .
from
On the other hand, the syntax also allows us to express the type of
join
what we are going to do, if it isinner
,left [outer]
,right [outer]
orfull outer
.The equivalent query using modern SQL syntax would look something like this: