mysql - get all records matching the query string and display like in google suggest by google -


what want is, similar google suggest. client page submit search text through ajax server. server grab text , query records matching string , return client page.

e.g. text_frm_client = "ba". query show records beginning "ba"


the raw sql query achieve problem

    **select * table_name column1 "ba%" or column2 "ba%"** 

now want port query django model. found somewhat similar. https://docs.djangoproject.com/en/dev/ref/models/querysets/#std:fieldlookup-contains

but 1 field. how can accomplish sql query django model.

you can use q

data = mymodel.objects.filter(         q(column1__contains="ba") |          q(column2__contains="ba")         ) 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -