Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
209 views
in Technique[技术] by (71.8m points)

MySQL counting how many times a value is called

I'm trying to get into databases and have a sample database with tables regarding tables. I want to write out all departures that are occuring in the database and write how many of them are happening.

SELECT l.location 
  FROM locations l
 WHERE EXISTS
     (SELECT d.departureLocCode 
       FROM trip_directory d
      WHERE l.LocationCode = d.departureLocCode);

This is what I have now and it writes out the depratures I need.

However, when I try using count(location) in this example I only get the first location printed out with the number of times departures occur instead of how many times each one of them occured.

Any suggestions?

question from:https://stackoverflow.com/questions/65944825/mysql-counting-how-many-times-a-value-is-called

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...