SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
-
Nov 29, 2009, 06:37 #1
- Join Date
- Oct 2006
- Posts
- 139
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Subquery to count value based upon variable in parent query
I am trying to use a variable from a column in the first select to populate the against clause in the second query.
Code:select m.menuitem, m.menuname,m.menutype, @a := m.menusearch, (select count(*) as total from nametable where match(name) against (@a) ) as total from menu m
-
Nov 29, 2009, 07:34 #2
- Join Date
- Jul 2002
- Location
- Toronto, Canada
- Posts
- 39,347
- Mentioned
- 63 Post(s)
- Tagged
- 3 Thread(s)
have you tried this...
Code:SELECT m.menuitem , m.menuname , m.menutype , m.menusearch , ( SELECT COUNT(*) FROM nametable WHERE MATCH(name) AGAINST ( m.menusearch ) ) AS total FROM menu AS m
-
Nov 29, 2009, 08:34 #3
- Join Date
- Oct 2006
- Posts
- 139
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
yes i tried this one and it gave me an error, "incorrect arguments AGAINST"
Not sure why it wont work
thx for help
-
Nov 29, 2009, 14:06 #4
- Join Date
- Oct 2006
- Posts
- 139
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
please help
Bookmarks