Home>
When outputting data with sql, I want to avoid displaying duplicate data for each shop.
The problem i am havingselect * from table name;
id | shop | name | price
1 | a | Curry | 100
2 | a | Curry | 120
3 | a | Soba | 100
4 | a | Udon | 100
5 | a | Set meal | 100
6 | b | Curry | 130
7 | b | Soba | 140
8 | b | Katsudon | 100
..
..
..
When there was a table called
I want to output as follows.
id | shop | name | price
1 | a | Curry | 100
3 | a | Soba | 100
4 | a | Udon | 100
5 | a | Set meal 100 |
6 | b | Curry | 130
7 | b | Soba | 140
8 | b | Katsudon | 100
..
..
..
I want to retrieve duplicate data for each shop with the same value.
There were two names called curry in the id of a, so I want to make one, but I want to keep the curry in the table of b.
Since it is only necessary to narrow down the curry value of name to one, there is no condition such as wanting to extract the cheaper curry.
I'm at a loss because I don't know how to write SQL statements ...
Supplementary information (FW/tool version, etc.)Rails 6.0.3.4
sqlite3
-
Answer # 1
Related articles
- ruby - [rails] duplicate column name: it is displayed as reset_sent_at, but i do not know the duplicated part
- ruby - i want to avoid repeated if statements in rails view
- ruby - [rails] i want to change the argument of link_to using conditional branching
- ruby on rails 6 - i changed the project name of rails, but it became inaccessible
- ruby on rails - i want to jump to the action of another controller with render
- ruby on rails - heroku: how to check the database_url used for regular backup
- ruby on rails 5 - i want to update the received parameters with nil
- ruby on rails - it is not saved in the database after registering the product
- ruby on rails - mvc rails
- ruby - rails tutorial chapter 2 (6th edition)
- ruby on rails - rails6 rspec model run-time error nomethoderror: undefined method `valid?'for nil: nilclass
- ruby - about "activemodel :: unknownattributeerror" of rails
- ruby on rails - saved description in nested controller
- ruby on rails - cart function routing error cannot be resolved
- ruby on rails - rails s can't
- ruby on rails - how to transition from the top page
- ruby on rails - i want to implement a function for administrator users to register luggage for general users in rails
- ruby on rails - things associated with a foreign key cannot be called in view
- ruby on rails 6 - environment construction of ruby on rails
Trends
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- javascript - how to check if an element exists in puppeteer
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file
- i want to call a child component method from a parent in vuejs
- python 3x - typeerror: 'method' object is not subscriptable
Well, I think this is fine.