Forum Moderators: coopster

Message Too Old, No Replies

Searching multi tables for match

mySQL PHP search

         

Gruessle

7:34 am on Mar 28, 2005 (gmt 0)

10+ Year Member



I need a mySQL/PHP search which seams to be way over my head and I was wondering if someone could give me a hand here.
Now to me everything I wrote makes sense I read it 3 times I hope I am not assuming anything here:

I have a total of 14 tables
Table 1 just defines the Name
Table 2 has 3 jobs
1)It sets the status of the entry as in search able or not search able
2)It records the last updated date, which is not an important entry while searching.
3)It binds the sid and pid numbers

All other tables set criteria, some with numbers others are words, All words are select option items not random text. To make it easy I will only use numbers here.

Every Table1 Name entry minimum has one full set of criteria tables (I will call this here the main criteria) but also may have additional criterias (I will call these here subcriterias)

The subcriterias must have at leased two criteria table entries to differentiate them selfs from the main criteria.

Imagen this:
Name1 has main criteria in citeria table 1=100 in 2=200 and 3=300
If someone would search for citeria 1=100, 2=200 and 3=300 this would be a match clear right.
Now Name1 may also have sub criterias as follows
SubCriteria1=> table2=250 and table 3=350
SubCriteria2=> table1=350 and table 3=150
SubCriteria3=> table2=250 and table 2=300

If someone would search for citeria 1=350, 2=200 and 3=150
He should have a match at Name1 SubCriteria2

When searching we will always need a full set match.

Below is a more visual table layout.

Hmm I think I am done explaining I hope this isn't to hard and if you can't help me then thank you for even reading this far.

pid ¦ Name
---------------------
1 ¦ Name1
---------------------
2 ¦ Name2
---------------------
3 ¦ Name3

sid ¦ Status ¦ Last_Update ¦ pid
-------------------------------------
1 ¦ 0 ¦ 2005-03-28 ¦1
-------------------------------------
2 ¦ 0 ¦ 2005-03-28 ¦1
-------------------------------------
3 ¦ 0 ¦ 2005-03-28 ¦2
-------------------------------------
4 ¦ 0 ¦ 2005-03-28 ¦3
-------------------------------------
5 ¦ 0 ¦ 2005-03-28 ¦3
-------------------------------------
6 ¦ 0 ¦ 2005-03-28 ¦2

id ¦ no1 ¦ sid
-------------
1 ¦ 300 ¦ 1
-------------
2 ¦ 500 ¦ 3
-------------
3 ¦ 450 ¦ 6
-------------
4 ¦ 600 ¦ 1
-------------
5 ¦ 700 ¦ 4
-------------
6 ¦ 750 ¦ 5
-------------
7 ¦ 325 ¦ 2
-------------
8 ¦ 400 ¦ 6

id ¦ no2 ¦ sid
-------------
1 ¦ 300 ¦ 1
-------------
2 ¦ 500 ¦ 3
-------------
3 ¦ 450 ¦ 6
-------------
4 ¦ 600 ¦ 1
-------------
5 ¦ 700 ¦ 4
-------------
6 ¦ 750 ¦ 5
-------------
7 ¦ 325 ¦ 2
-------------
8 ¦ 400 ¦ 6

id ¦ no3 ¦ sid
-------------
1 ¦ 300 ¦ 1
-------------
2 ¦ 500 ¦ 3
-------------
3 ¦ 450 ¦ 6
-------------
4 ¦ 600 ¦ 1
-------------
5 ¦ 700 ¦ 4
-------------
6 ¦ 750 ¦ 5
-------------
7 ¦ 325 ¦ 2
-------------
8 ¦ 400 ¦ 6

id ¦ no4 ¦ sid
-------------
1 ¦ 300 ¦ 1
-------------
2 ¦ 500 ¦ 3
-------------
3 ¦ 450 ¦ 6
-------------
4 ¦ 600 ¦ 1
-------------
5 ¦ 700 ¦ 4
-------------
6 ¦ 750 ¦ 5
-------------
7 ¦ 325 ¦ 2
-------------
8 ¦ 400 ¦ 6

coopster

10:40 pm on Mar 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I have to be honest, Gruessle, I've read through this post at least as many times as you have and I can't quite understand what you are asking :)

Could you maybe document the relationships between the table keys and show exactly what type of search you are trying to generate?