question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How implement this query

See original GitHub issue
SELECT "a".* FROM "accounts" a, account_phones p, account_emails e, WHERE 
  (p.phone ilike '%11111111111%' OR  e.email ilike '%11111111111%') 
  AND a.id = p.account_id 
  AND a.id = e.account_id
ORDER BY "id" DESC;

I do

db.Accounts.findAll({
  where: where,
  include: [
    {model: db.AccountEmail, where: whereEmail, required: false },
    {model: db.AccountPhone, where: wherePhone, required: false }
  ]
})

and it no worked

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:20 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
janmeiercommented, Aug 17, 2015
Profile.findAll({
  where: sequelize.where(
    sequelize.cast(sequelize.col('profile.member_dob'), 'INTEGER'),
    {$ilike:'%'+'0811'+'%'}
  )
});
1reaction
janmeiercommented, Apr 20, 2015

Try something like

where = {
  $or: [
    { first_name: { $ilike: '%' + q  + '%'% }},
    { last_name: { $ilike: '%' + q  + '%'% }}
    ....,
    sequelize.where(sequelize.col('account_emails.email'), { $ilike: '%' + q + '%')
  ]
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

What are the Best Ways to Write a SQL Query? - GeeksforGeeks
1. Provide Correct Formatting for the Query · Put each statement in the query in a new line. · Put SQL keywords in...
Read more >
An Introductory SQL Tutorial: How to Write Simple Queries
Learn how to get started with this beginner's guide to writing simple SQL queries.
Read more >
How to Create a SQL Statement - UCSD Blink
1. Start your query with the select statement. · 2. Add field names you want to display. · 3. Add your statement clause(s)...
Read more >
Learn to write basic SQL Queries - SQLShack
The goal of this article is to gain the ability to write basic SQL queries for the beginners.
Read more >
Implementing Query-by-Example - 4Js
This program implements query-by-example, using the CONSTRUCT statement to allow the user to enter search criteria in a form. The criteria is used...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found