Ok so I dont know if you can do the following, but here is what I want to do:
I have 2 tables with structures/content sort of like the following:
So here is what I am currently doing:
So this returns 3 rows in essence (from table 1: 1,2,5) And seems to always choose the largest number. What I want it to do is limit this...
I want to make it so that for each object in table2 I want it to go through table1 and select only the first one (or last one, or middle one... in essence I just want it to pick up one and none more)... so in essence I want the number of elements in table2 to limit the number of total elements selected.
Let me know if this is possible and how I would do this. I'm fairly new to MySQL so Im trying to learn. Thanks!
I have 2 tables with structures/content sort of like the following:
Code:
table1: id | name 1 | Jack 2 | Jack 3 | Jill 4 | Adam 5 | Amy table2: id | name 1 | Jack 2 | Amy
Code:
SELECT * FROM table1, table2 WHERE table1.name=table2.name;
I want to make it so that for each object in table2 I want it to go through table1 and select only the first one (or last one, or middle one... in essence I just want it to pick up one and none more)... so in essence I want the number of elements in table2 to limit the number of total elements selected.
Let me know if this is possible and how I would do this. I'm fairly new to MySQL so Im trying to learn. Thanks!
Comment