# Search in several fields in table

**URL:** <https://forum.wixstudio.com/t/search-in-several-fields-in-table/30415>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [December 26, 2017, 3:08pm UTC](https://forum.wixstudio.com/t/search-in-several-fields-in-table/30415 "2017-12-26T15:08:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![alan-billyeald](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/alan-billyeald/32/1349_2.png) [@alan-billyeald](https://forum.wixstudio.com/u/alan-billyeald)\
**Post date:** [December 26, 2017, 3:08pm UTC](https://forum.wixstudio.com/t/search-in-several-fields-in-table/30415/1 "2017-12-26T15:08:16Z")

</div>

Hello, I am relatively new to creating websites using Wix and very new at Wix code.  
I have created a dynamic contacts page and have managed to make it search (Søk) for a contact name (Navn) using this code:

import wixData from ‘wix-data’;  
//For full API documentation, including code examples visit [Velo API Reference - Wix.com](http://wix.to/94BuAAs)

$w.onReady(function () {  
//TODO: import wixData from ‘wix-data’;  
});

export function button1\_click(event) {  
wixData.query(‘TCM2018’)

.contains(‘navnKomplett’, $w(‘#input1’).value)

.find()  
.then(res =\> {  
$w(‘#table1’).rows = res.items;  
});  
}

I need help with the code so that it seaches in several fields. I would like to be able to search either by name or by number (Medlemsnr).

Any suggestions or help is greaty appreciated.  
Thanks and seasons greetings  
Alan

 ![](https://us1.discourse-cdn.com/wix/original/3X/1/c/1c96e86388d2a1b32b797aa2b921838b0498b517.png)

---

<div class="post-metadata">

**Author:** ![admin-23](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/admin-23/32/708_2.png) [@admin-23](https://forum.wixstudio.com/u/admin-23)\
**Post date:** [December 27, 2017, 9:37am UTC](https://forum.wixstudio.com/t/search-in-several-fields-in-table/30415/2 "2017-12-27T09:37:05Z")

</div>

Hi Alan,

To chain a number of queries together, use the following syntax:

```javascript
  wixData.query('test1')
   .or(wixData.query('test1').contains('title', $w('#nameInput').value))
   .or(wixData.query('test1').gt('age', $w('#numberInput').value))
   .or(wixData.query('test1').lt('age', $w('#numberInput').value))
   .find()
   .then(res => {   
      console.log(res);
    });
}

```

---

<div class="post-metadata">

**Author:** ![alan-billyeald](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/alan-billyeald/32/1349_2.png) [@alan-billyeald](https://forum.wixstudio.com/u/alan-billyeald)\
**Post date:** [December 29, 2017, 4:23pm UTC](https://forum.wixstudio.com/t/search-in-several-fields-in-table/30415/3 "2017-12-29T16:23:16Z")

</div>

Hi Ido, thanks very much for reaching out. I have tried to do as you say for a couple of days now but I am quite stuck. Can you say what “age” refers to? Is it the members number field?

---

<div class="post-metadata">

**Author:** ![roi-bendet](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/roi-bendet/32/1283_2.png) [@roi-bendet](https://forum.wixstudio.com/u/roi-bendet)\
**Post date:** [December 31, 2017, 10:33am UTC](https://forum.wixstudio.com/t/search-in-several-fields-in-table/30415/4 "2017-12-31T10:33:47Z")

</div>

Hi Alan,  
It refers to the field key in the database collection.  
Where did you get stuck ?

---

<div class="post-metadata">

**Author:** ![alan-billyeald](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/alan-billyeald/32/1349_2.png) [@alan-billyeald](https://forum.wixstudio.com/u/alan-billyeald)\
**Post date:** [December 31, 2017, 3:06pm UTC](https://forum.wixstudio.com/t/search-in-several-fields-in-table/30415/5 "2017-12-31T15:06:12Z")

</div>

Hi Roi and thanks for contacting.  
I have a collection of club members and I have it so I can search bt member name and that works. I would like to be able to search either by name or number form the same search box and that is where I am stuck. I tried the syntax provided by Ido (above) but I guess I just do not have any coding knowledge, I think I need to see the complete code and then work on that to see exactly how it works. I have also tried with 2 seach boxes ( one for number and one for name) which would be a heavy handed solution but alas …no go.  
See next entry for next image

 ![](https://us1.discourse-cdn.com/wix/original/3X/0/9/098ab4ff4bf5efd93cc6a5e1d2063119714349c7.png)

---

<div class="post-metadata">

**Author:** ![alan-billyeald](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/alan-billyeald/32/1349_2.png) [@alan-billyeald](https://forum.wixstudio.com/u/alan-billyeald)\
**Post date:** [December 31, 2017, 3:09pm UTC](https://forum.wixstudio.com/t/search-in-several-fields-in-table/30415/6 "2017-12-31T15:09:19Z")

</div>

Hi Roi  
I want to search by Navn komplett (name) or Medlemsnr (Number)  
My site is www.travellersclub.no and if you apply for membership I can let you in so you can see?  
Thanks  
Alan

 ![](https://us1.discourse-cdn.com/wix/original/3X/6/a/6a2d073a034a87145516cefee1018509809d7f07.png)
