Skip to content

Instantly share code, notes, and snippets.

@tekihei2317
Last active August 25, 2021 23:24
Show Gist options
  • Select an option

  • Save tekihei2317/2964e488a684b074e172e23c60e5e5ab to your computer and use it in GitHub Desktop.

Select an option

Save tekihei2317/2964e488a684b074e172e23c60e5e5ab to your computer and use it in GitHub Desktop.
laravel-realworld-example-appのテストで実行されていた、select文の一覧(pt-query-digestの解析結果から抽出)
-- select * from `migrations` where `migration` = '2017_04_27_200850_create_follows_table'\G
-- select * from `migrations` where `batch` = 1 order by `migration` desc\G
-- select * from information_schema.tables where table_schema = 'realworld_test' and table_name = 'migrations'\G
-- select `migration` from `migrations` order by `batch` asc, `migration` asc\G
select `slug` = 'new-title', `title` = 'new title', `description` = 'new description', `body` = 'new body with random text', `updated_at` = '2021-08-25 12:22:27' from `articles` where `id` = 1\G
select `username` = 'test12345', `email` = 'test12345@test.com', `password` = 'test12345', `bio` = 'hello', `image` = 'http://test.com/test.jpg', `updated_at` = '2021-08-25 12:22:40' from `users` where `id` = 1\G
select * from `articles` where `id` = 1\G
select * from `comments` where `id` = 1\G
select * from `favorites` where `user_id` = 2 and `article_id` in (1)\G
select * from `follows` where `follower_id` = 1 and `followed_id` in (2)\G
select * from `articles` where `slug` = 'ut-magni-consequatur-facere-dolorum-natus' or `slug` LIKE 'ut-magni-consequatur-facere-dolorum-natus-%'\G
select * from `articles` where `slug` = 'voluptas-iusto-est-quasi-quibusdam' limit 1\G
select * from `comments` where `comments`.`article_id` = 1 and `comments`.`article_id` is not null order by `created_at` desc\G
select * from `comments` where `id` = '1' limit 1\G
select * from `tags` where (`name` = 'coding') limit 1\G
select * from `tags` where `name` = 'somerandomtag' limit 1\G
select * from `tags`\G
select * from `users` where `email` = 'shanahan.raphaelle@example.com' limit 1\G
select * from `users` where `id` = 1 limit 1\G
select * from `users` where `username` = 'arnulfo30' limit 1\G
select * from `users` where `username` = 'test12345' and `email` = 'test12345@test.com' and `bio` = 'hello' and `image` = 'http://test.com/test.jpg' limit 1\G
select * from `users` where `users`.`id` = 1 limit 1\G
select * from `users` where `users`.`id` in (2)\G
select * from `users`\G
select `article_id` from `articles` inner join `article_tag` on `articles`.`id` = `article_tag`.`article_id` where `article_tag`.`tag_id` = 1 order by `created_at` desc\G
select `articles`.*, (select count(*) from `users` inner join `favorites` on `users`.`id` = `favorites`.`user_id` where `articles`.`id` = `favorites`.`article_id`) as `favorited_count` from `articles` order by `created_at` desc limit 20 offset 0\G
select `articles`.*, (select count(*) from `users` inner join `favorites` on `users`.`id` = `favorites`.`user_id` where `articles`.`id` = `favorites`.`article_id`) as `favorited_count` from `articles` where 0 = 1 order by `created_at` desc limit 20 offset 0\G
select `articles`.*, (select count(*) from `users` inner join `favorites` on `users`.`id` = `favorites`.`user_id` where `articles`.`id` = `favorites`.`article_id`) as `favorited_count` from `articles` where `id` in (3, 2, 1) order by `created_at` desc limit 20 offset 0\G
select `articles`.*, (select count(*) from `users` inner join `favorites` on `users`.`id` = `favorites`.`user_id` where `articles`.`id` = `favorites`.`article_id`) as `favorited_count` from `articles` where `user_id` = 2 order by `created_at` desc limit 20 offset 0\G
select `articles`.*, (select count(*) from `users` inner join `favorites` on `users`.`id` = `favorites`.`user_id` where `articles`.`id` = `favorites`.`article_id`) as `favorited_count` from `articles` where `user_id` in (2) order by `created_at` desc limit 20 offset 0\G
select `articles`.*, (select count(*) from `users` inner join `favorites` on `users`.`id` = `favorites`.`user_id` where `articles`.`id` = `favorites`.`article_id`) as `favorited_count` from `articles` where `user_id` is null order by `created_at` desc limit 20 offset 0\G
select `id` from `articles` inner join `favorites` on `articles`.`id` = `favorites`.`article_id` where `favorites`.`user_id` = 2\G
select `id` from `users` inner join `follows` on `users`.`id` = `follows`.`followed_id` where `follows`.`follower_id` = 1\G
select `slug` from `articles` where `articles`.`user_id` = 2 and `articles`.`user_id` is not null order by `created_at` desc, `created_at` desc limit 10 offset 5\G
select `tags`.*, `article_tag`.`article_id` as `pivot_article_id`, `article_tag`.`tag_id` as `pivot_tag_id` from `tags` inner join `article_tag` on `tags`.`id` = `article_tag`.`tag_id` where `article_tag`.`article_id` = 2\G
select `tags`.*, `article_tag`.`article_id` as `pivot_article_id`, `article_tag`.`tag_id` as `pivot_tag_id` from `tags` inner join `article_tag` on `tags`.`id` = `article_tag`.`tag_id` where `article_tag`.`article_id` in (1)\G
select `users`.*, `favorites`.`article_id` as `pivot_article_id`, `favorites`.`user_id` as `pivot_user_id`, `favorites`.`created_at` as `pivot_created_at`, `favorites`.`updated_at` as `pivot_updated_at` from `users` inner join `favorites` on `users`.`id` = `favorites`.`user_id` where `favorites`.`article_id` in (1, 2) and `user_id` is null\G
select `users`.*, `favorites`.`article_id` as `pivot_article_id`, `favorites`.`user_id` as `pivot_user_id`, `favorites`.`created_at` as `pivot_created_at`, `favorites`.`updated_at` as `pivot_updated_at` from `users` inner join `favorites` on `users`.`id` = `favorites`.`user_id` where `favorites`.`article_id` in (6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25) and `user_id` = 1\G
select `users`.*, `follows`.`followed_id` as `pivot_followed_id`, `follows`.`follower_id` as `pivot_follower_id`, `follows`.`created_at` as `pivot_created_at`, `follows`.`updated_at` as `pivot_updated_at` from `users` inner join `follows` on `users`.`id` = `follows`.`follower_id` where `follows`.`followed_id` in (2) and `follower_id` = 1\G
select `users`.*, `follows`.`followed_id` as `pivot_followed_id`, `follows`.`follower_id` as `pivot_follower_id`, `follows`.`created_at` as `pivot_created_at`, `follows`.`updated_at` as `pivot_updated_at` from `users` inner join `follows` on `users`.`id` = `follows`.`follower_id` where `follows`.`followed_id` in (2) and `follower_id` is null\G
select count(*) as aggregate from `articles` inner join `favorites` on `articles`.`id` = `favorites`.`article_id` where `favorites`.`user_id` = 1 and `article_id` = 1\G
select count(*) as aggregate from `articles` where 0 = 1\G
select count(*) as aggregate from `articles` where `id` in (3, 2, 1)\G
select count(*) as aggregate from `articles` where `user_id` = 2\G
select count(*) as aggregate from `articles` where `user_id` in (2)\G
select count(*) as aggregate from `articles` where `user_id` is null\G
select count(*) as aggregate from `articles`\G
select count(*) as aggregate from `users` inner join `favorites` on `users`.`id` = `favorites`.`user_id` where `favorites`.`article_id` = 1\G
select count(*) as aggregate from `users` inner join `follows` on `users`.`id` = `follows`.`followed_id` where `follows`.`follower_id` = 1 and `followed_id` = 2\G
select count(*) as aggregate from `users` where `email` = 'heller.aurelia@example.org'\G
select count(*) as aggregate from `users` where `email` = 'kassulke.lorenzo@example.net' and `id` <> 1\G
select count(*) as aggregate from `users` where `username` = 'noelfarrell'\G
select count(*) as aggregate from `users` where `username` = 'test12345' and `id` <> 1\G
select max(`batch`) as aggregate from `migrations`\G
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment