Note that there are some explanatory texts on larger screens.

plurals
  1. POElixir/SQLAlchemy equivalent to SQL "LIKE" statement?
    text
    copied!<p>I'm using the MySQLicious type schema described <a href="http://www.pui.ch/phred/archives/2005/04/tags-database-schemas.html" rel="noreferrer">here</a> for a simple tagging system. I've read some alternative implementations of tagging schema in 4 different SO threads, and this suits my needs best.</p> <p>A collection of entries have the tags "apple banana orange" and "strawberry banana lemon", and I'm trying to find the Elixir/SQLAlchemy equivalent statement to</p> <pre><code>SELECT * FROM table WHERE tags LIKE "%banana%"; </code></pre> <p>I haven't been able to find any such way to structure a Class.query.filter/filter_by() command, and can't see a similar method in the documentation for either module. Is there a simple way to do this? Or should I just use raw SQL.</p> <p>Extra Question: A disadvantage of the MySQLicious schema is the case where I may wish to search for "%apple%" but have "pineapple" returned. Is there a high level way to deal with this test case? Or should I just include a leading space in each query?</p> <p>n.B: For those who care, this is my first experience with databases, so I may be overlooking core advantages of the schema mentioned in other threads. My application is for logging a sentence or two about a task completed, with columns [TaskID, Tags, Notes, StartTime, StopTime, TimeTaken], a bit like a simple journal. Mostly for tutorial purposes. I want to be able to search by individual tags to find out roughly how much time I spend on a given task.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload