2016-07-22 29 views
0

我使用的查詢讓所有的多個標籤在我的表限制的MySQL結果時的列值改變

$query=mysqli_query($conn,"select * from job_tags where tag_name in (
    select tag_name from job_tags group by tag_name having count(*) > 1 
) ORDER BY tag_name"); 

我得到的結果是這樣

tag_id---tag_name 



     5576----01-12-2015 
     5222----01-12-2015 
     5247----01-12-2015 
     6162----01-12-2015 
     6265----01-12-2015 
     5291----01-12-2015 
     7159----B.Com 
     7895----B.Com 
     7692----B.Com 
     8149----B.Com 
     8289----B.Com 
     8228----B.Com 
     8045----B.Com 
     8362----B.Com 
     7793----B.Com 
     5760----02-12-2015 
     5030----02-12-2015 
     5945----02-12-2015 
     4703----02-12-2015 
     5571----02-12-2015 
     4580----02-12-2015 
     4826----02-12-2015 
     5593----02-12-2015 
     5221----02-12-2015 
     5478----02-12-2015 
     5649----02-12-2015 
     4867----02-12-2015 
     6266----02-12-2015 
     5292----02-12-2015 
     5479----03-12-2015 
     5220----03-12-2015 
     5250----03-12-2015 
     5899----03-12-2015 
     5840----03-12-2015 
     5293----03-12-2015 
     5573----03-12-2015 
     5575----03-12-2015 
     5736----03-12-2015 
    etc .... 

我只想要顯示第一頁中的第一標籤的倍數和另一頁中的第二標籤的倍數。

這就是我想確切結果限制在標籤名稱的變化(我在我的表超過6000個標籤)

任何幫助是非常讚賞

編輯----- -

預期輸出

冷杉ST頁面

5576----01-12-2015 
5222----01-12-2015 
5247----01-12-2015 
6162----01-12-2015 
6265----01-12-2015 
5291----01-12-2015 

第二頁

 7159----B.Com 
     7895----B.Com 
     7692----B.Com 
     8149----B.Com 
     8289----B.Com 
     8228----B.Com 
     8045----B.Com 
     8362----B.Com 
     7793----B.Com 

等..........

+1

可以顯示輸出你想 – urfusion

+0

肯定。可以請你檢查我的編輯 – Lakshmi

+0

你的意思是你想每頁當天顯示的記錄? – KaeL

回答

0

你只需要一個條件選擇首選TAG_NAME。因此我在查詢中使用了$ tag_name。然後你只需要一個腳本來確定「正確」的標籤名稱。使用運營商的'LIKE',也可以使用諸如'%'的通配符,例如選擇所有標籤,就像您之前已經完成的那樣。

$query=mysqli_query($conn," 
select * from job_tags 
where tag_name in (
    select tag_name from job_tags group by tag_name having count(*) > 1) 
and tag_name LIKE '$tag_name'"); 
+0

感謝您的回覆:)我有成千上萬的'$ tag_name',我想在標籤名稱更改時限制結果。這不是輸出 – Lakshmi