2016-06-09 12 views
1

Mysql Syntaxfehler. Mit concat muss ich ein drittes Feld auf 100 Zeichen beschränken. Dieser Code gibt das gesamte Feld nicht auf 100 Zeichen beschränkt zurück.Mysql Syntax - Concat und Limit Länge des Feldes

SELECT CONCAT('<a href="',posts_network.guid,'">',posts_network.post_title,'</a>','<p>',posts_network.post_content,100,'</p>') AS network_title_with_link_to_post FROM am_posts AS posts_network WHERE 1=1 AND posts_network.post_type = 'network' 

Die post_content zeigen das gesamte Feld, nicht auf 100 Zeichen beschränkt.

Antwort

2

Verwendung subtsr

SELECT CONCAT('<a href="',posts_network.guid,'">' 
      ,posts_network.post_title,'</a>' 
      ,'<p>' 
      ,substr(posts_network.post_content,1,100), 
      '</p>') AS network_title_with_link_to_post 
FROM am_posts AS posts_network 
WHERE 1=1 
AND posts_network.post_type = 'network' 
+0

perfekte Lösung. Danke Edge. – user2821847