Column filter based on two database columns

Column filter based on two database columns

ilbrambiilbrambi Posts: 3Questions: 1Answers: 0

Hi,
i need to filter some columns by two database columns.
ex:
table store
store = 1

table store attributes
store= 1, attr_type=facebook_page,attr_value=....

I need to search a column with a select box (already implemented). How can i add a 'and ....' in the where condition inside the search query?

Answers

  • ilbrambiilbrambi Posts: 3Questions: 1Answers: 0

    I've already implemented all the logic and structure, i just need to know if it's possible to edit and append a second where condition in the automatic search query on columns.
    Thx in advance

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    Hi ilbramdi,

    I'm not sure if I follow your question, but when you do a column search, if you give two strings separated with a space, i.e. 'bra gre", then both those search terms are ANDed together, i.e. it'll match "Bradley Greer".

    If I'm missing something, would you be able to do a live example to demonstrate the issue, please.

    Cheers,

    Colin

  • ilbrambiilbrambi Posts: 3Questions: 1Answers: 0

    Hi colin, thx in for your reply.
    The problem i'm facing is hard to reproduce in a live example so i'll try to be more exaustive:
    i've already made the column filters ecc and everything is working fine except for 5 columns that i need to filter with 2 database column at the same time:
    the search query should be like
    "select * from table where database_column1 like '%value1%' and database_column2 like '%value2%'
    but the search query always provide just one 'where' without the possibility to make the 'and ...' part of the query with a custom database_column2.
    Is there a way to submit a second part of the query or make a custom request?
    hope you understand my issue

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    Hi again,

    I think I'm being slow, I apologise, but I'm not sure how the five DataTables columns are being mapped/filtered by the two SQL tables. If you are using server-side processing, there would be no restriction, as that server-side script (which can contain whatever select logic you want) applies the search filtering.

    Cheers,

    Colin

  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67
    edited February 2018

    If you are using client side then you can use yadcf to do the filtering based on multiple columns (using single input), see showcase example

    http://yadcf-showcase.appspot.com/dom_multi_columns_tables_1.10.html

This discussion has been closed.