I'm thinking of a sql requesting a one-to-many search,
Could you help me because I got stuck?
About blog tags and author search.
blogid // id of blog_main
blogid // id of blog_main
Multiple "blog_tag" and "blog_auther" are recorded in "blog_main".
I want to create a sql with tagid 2,4 registered and autherid1,4 registered. Is there any good idea?
Currently I have come up with a sql that only searches for "tag", but I can't think of anything that adds "auther" to it.
The following is a tag-only sql. I am using mysql.
select * from blog_main AS t1 where exists ( select 1 from blog_tag AS t2 where t1.id = t2.blogid and t2.tagid in (2, 4) having count (*) = 2 );
Answer # 1
Simply adding conditions in the same way?
select * from blog_main AS t1 where exists ( select 1 from blog_tag AS t2 where t1.id = t2.blogid and t2.tagid in (2, 4) having count (*) = 2 ) and exists ( select 1 from blog_auther AS t2 where t1.id = t2.blogid and t2.autherid in (1, 4) having count (*) = 2 )
Answer # 2
select * from blog_main bm where exists ( select 1 from blog_tag bt where bm.id = bt.blogid and bt.tagid in (2, 4) ) and exists ( select 1 from blog_auther ba where bm.id = ba.blogid and ba.autherid in (1, 4) ) ;
Can you close like this? . . ?
- mysql - i want to get the number of characters included in the search in sql
- mysql - call model in viewhelper and pass the search result to view
- c# - i want to reflect the search results of mysql to gridview
- how to write "data corresponding to all one-to-many" by passing one of "many" in mysql "one-to-many&quo
- i want to make a refined search with php and mysql
- mysql - i want to do a full text search
- java - mysql jdbc search results are different
- i want to implement a tag search function in mysql
- about mysql fuzzy search
- Detailed analysis of the MySQL slow search log opening method and storage format
- MySQL full text fuzzy search MATCH AGAINST method example
- MySQL one-to-many related query paging error solution
- python 3x - typeerror: 'method' object is not subscriptable
- python - you may need to restart the kernel to use updated packages error
- xcode - pod install [!] no `podfile 'found in the project directory
- vuejs - [vuetify] unable to locate target [data-app] i want to unit test to avoid warning
- android studio - emulator: dsound: could not initialize about the error message directsoundcapture
- android studio - unresolved reference comes out in kotlin
- mysql startup failed [error] innodb: the innodb_system data file 'ibdata1' must be writable
- django - oserror: [winerror 123] the file name, directory name, or volume label syntax is incorrect : '<frozen importlib_boot
- python - importerror: cannot import name md5 error cannot be resolved