Questions tagged [sql-match-all]

51 questions
2
votes
1 answer

Joining 3 tables SQL

I am trying to solve this problem for quite some time and the output is wrong. Can anyone help me with this? I am using mysql, so full join doesnt work. Thank yyou 3 tables: Frequents (attributes: drinker, bar, times_a_week), Likes (attributes:…
kaboom
  • 307
  • 6
  • 16
2
votes
1 answer

Efficient way to get all articles with a set of tags in MySQL

I need an efficient way to select all articles with at least tags "Tag1" and "Tag2". This is the standart way with the following database schema: articles(id, title) article_tag(articleid, tagid) tag(id, name) SELECT a.* FROM article a INNER…
evodevo
  • 479
  • 1
  • 7
  • 14
2
votes
3 answers

how to get records in the following scenario

I have a table like below : node_name id term_name ---------------------------------------------- test1 001 physics test1 001 maths test1 001 …
Fero
  • 12,969
  • 46
  • 116
  • 157
2
votes
5 answers

Equivalent of "IN" that uses AND instead of OR logic?

I know I'm breaking some rules here with dynamic SQL but I still need to ask. I've inherited a table that contains a series of tags for each ticket that I need to pull records from. Simple example... I have an array that contains…
Ryan Dunphy
  • 792
  • 2
  • 10
  • 33
2
votes
5 answers

Join: three tables and a or condition

I think I should know this somehow, especially after reading a lot of questions and answers regarding "The condition must go into the ON clause, not in the WHERE clause". However, I am still lost. I have three tables, and I join them normally with…
Narretz
  • 4,769
  • 32
  • 40
2
votes
4 answers

SQL question: excluding records

I have a database (NexusDB (supposedly SQL-92 compliant)) which contains and Item table, a Category table, and a many-to-many ItemCategory table, which is just a pair of keys. As you might expect, Items are assigned to multiple categories. I am…
Jamo
  • 3,238
  • 6
  • 40
  • 66
2
votes
1 answer

PostgreSQL conditional conjunction and disjunction in one query

How to create a query which selects products of given features where feature statement is formed by "and" or "or" condition depending on a group they belong to? Description of the situation There is a store with products. Products may have features…
rafis
  • 233
  • 2
  • 4
  • 10
2
votes
2 answers

HABTM Query help

I have a HABTM relationship between 'articles' and 'tags' Problem: I'm only looking for articles with BOTH the tag 'sports' and 'outdoors' but not articles with only one of these tags. I tried this: SELECT DISTINCT article.id, article.name FROM…
cardflopper
  • 976
  • 2
  • 12
  • 19
2
votes
3 answers

SQL Query problem

Consider two table.Employee and Project.Employee table has fields like eid,ename.Project table has fields like pid,pname.Now,since an employee can work on many projects and a project can be done by many employees, therefore,as evident,there is a…
2
votes
2 answers

SQL Many To Many Select With Link Table

I am trying to make my keyword search as efficient as possible using the following 3 tables : tblImageFiles [ID, ImageURL] tblTags [ID,Tag] tblxImagesTags [ID, ImageID, TagID] (this is a linktable joining the above in a many-to-many…
Mike
  • 369
  • 1
  • 6
  • 24
2
votes
3 answers

SQL, only if matching all foreign key values to return the record?

I have two tables Table A type_uid, allowed_type_uid 9,1 9,2 9,4 1,1 1,2 24,1 25,3 Table B type_uid 1 2 From table A I need to return 9 1 Using a WHERE IN clause I can return 9 1 24
Jules
  • 7,568
  • 14
  • 102
  • 186
1
vote
2 answers

How can I find all the rows in a table that exclusively have related rows in a given list?

I have three tables. Think of them as the following: Recipes id | name 1 | Cookies 2 | Soup ... Ingredients id | name 1 | flour 2 | butter 3 | chicken ... Recipe_Ingredient recipe_id | ingredient_id 1 |…
Frew Schmidt
  • 9,364
  • 16
  • 64
  • 86
1
vote
3 answers

Checking Multiple Column Value

I'm trying to get col1 values for certain multiple col2 values. For example: I want to see col1 values for col2's "1, 2, 3, 4" values (that is "1" in col1). Another ex: col1 values for col2's "1, 2" are "1, 2". How can i manage to do this in SQL…
platypus
  • 706
  • 2
  • 18
  • 40
1
vote
1 answer

Django: performing a SQL match all in Django

I recently asked how to solve a simple SQL query. Turns out that there are many solutions. After some benchmarking i think this is the best one: SELECT DISTINCT Camera.* FROM Camera c INNER JOIN cameras_features fc1 ON c.id = fc1.camera_id AND…
santiagobasulto
  • 11,320
  • 11
  • 64
  • 88
1
vote
2 answers

Searching for items from char-separated text field in MySQL

I am building an application based on MySQL that allows users to search for some facilities. The facilities are stored in one TEXT column and they are represented as "|"-separated field. Here is the…
Jacek Francuz
  • 2,420
  • 8
  • 45
  • 61