Asked  7 Months ago    Answers:  5   Viewed   22 times
SELECT * FROM people 
WHERE
university='2' 
AND MATCH (lname,fname) AGAINST ('+massive' IN BOOLEAN MODE) 
OR (fname LIKE '%box%' OR lname LIKE '%box%') 

This query is allowing results to filter through other than those of university='2' how would I update this so it strictly only shows results where university = 2

The reason I have combined fulltext search with LIKE is because of the minimum letter count that full text search has and because I am on a shared hosting plan I am unable to modify the settings. As a result I have combined both full text and LIKE in order to accommodate

 Answers

50

Fix your parentheses

SELECT * FROM people 
WHERE
    university='2' 
    AND (MATCH (lname,fname) AGAINST ('+massive' IN BOOLEAN MODE) 
         OR fname LIKE '%box%' 
         OR lname LIKE '%box%') 

AND has higher precedence than OR, so university = '2' was only being combined with MATCH, not with the fname/lname tests.

Tuesday, June 1, 2021
 
Pwner
answered 7 Months ago
74

From the PHP Manual on mysqli_stmt::execute:

mysqli_stmt::execute -- mysqli_stmt_executeExecutes a prepared Query

Returns TRUE on success or FALSE on failure.


if ($stmt->execute()) { // exactly like this!
    $success = true;
}

You're doing it right... What's your dilemma?

Wednesday, March 31, 2021
 
Sauleil
answered 9 Months ago
69

The problem is covered on the github issues thread - https://github.com/flask-admin/flask-admin/issues/1588

Basically, the flask-admin pip package is out of date, in regards the latest sqlalchemy pip package. In that specific area,

cls, key = identity_key(instance=obj)

sqlalchemy is now returning 3 objects, but flask-admin is only expecting 2, hence the error.

The real solution for this is to wait until a new flask-admin version is uploaded to pip, until then, you've a few options.

  1. Manually go in and edit that fields.py file
  2. As detailed in that issues thread, limit sqlalchemy to version 1.2.0b3. You can do this in your requirements.txt file, or manually with a pip upgrade install, pip install --upgrade sqlalchemy==1.2.0b3
  3. As the fix is in flask-admin's master branch in their github repository, install that version of flask-admin with the pip location of git+https://github.com/flask-admin/flask-admin. Again, you do this in your requirements.txt file, or with a pip upgrade install, pip install --upgrade git+https://github.com/flask-admin/flask-admin.

My personal preference, and what I've done, is option 3. If you look through the code itself, it's a line the maintainers want to remove, anyway, and how they're dealing with it is better, and in general with these things, I prefer to go forward (latest version of flask-admin) rather than holding things back (rollback sqlalchemy to a previous version), and certainly better than manually editing the raw code.

Tuesday, August 3, 2021
 
Viralk
answered 4 Months ago
92

Go for a union :-

SELECT * FROM My_Table WHERE my_id IN
(
  SELECT AllIDs AS MyIDs FROM ATable WHERE @Local = 'True'
  UNION
  SELECT TeamIDs AS MyIDs FROM TeamTable WHERE @Local <> 'True'
)
Saturday, October 23, 2021
 
mschuett
answered 1 Month ago
44

You need to change the collation of the table COLUMN itself.

select collation_name, *
from sys.columns
where object_id = object_id('tblname')
  and name = 'stringdata';

If you're lucky it is as easy as (example)

alter table tblname alter column stringdata varchar(20) collate Modern_Spanish_CI_AS

But if you have constraints and/or schema bound references, it can get complicated.
It can be very difficult to work with a database with mixed collations, so you may want to re-collate all the table columns.

Saturday, November 13, 2021
 
Vlad
answered 2 Weeks ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
 
Share