MySQL一行多行
例如,我有两个表(MySQL一行多行,mysql,sql,wordpress,join,Mysql,Sql,Wordpress,Join,例如,我有两个表(person和skill) 我可以在SQL中得到以下结果: id | First_name | Last_name | Mail | concat(SKILL 1 name, SKILL 1 level) | concat(SKILL 2 name, SKILL 2 level) etc.. 让事情复杂一点,我只是想要一些技能,而不是全部 我看到了这一点,但我不想看到结果(有大量的技能) 有可能吗 Thx 要了解更多信息,我想在Wordpress中选择自定义帖子的所有帖子。
person
和skill
)
我可以在SQL中得到以下结果:
id | First_name | Last_name | Mail | concat(SKILL 1 name, SKILL 1 level) | concat(SKILL 2 name, SKILL 2 level) etc..
让事情复杂一点,我只是想要一些技能,而不是全部
我看到了这一点,但我不想看到结果(有大量的技能
)
有可能吗
Thx
要了解更多信息,我想在Wordpress中选择自定义帖子的所有帖子。我有第一个表
post
(带有标题
,日期
等)和表wp\u postmeta
(每个meta
有一行)
因此,我需要一个请求,在一行中选择post
和meta的信息:ID,TITLE,LAST\u UPDATE,CONCAT(meta\u key1,meta\u value1),CONCAT(meta\u key1,meta\u value1)
我有两张桌子:
- wp_员额
- 帖子id、帖子作者、帖子日期、帖子日期gmt、帖子内容、, 帖子标题,帖子类型
- 邮差
- 元id、后id、元密钥、元值
SELECT * FROM wp_posts LEFT JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id WHERE post_type = 'user'
结果我有多排。我只想要一个我在我的问题上找到了答案 我必须使用对象WP_查询,我希望下面的代码能帮助其他人
global $wpdb;
$args = array('post_type' => 'user');
$result_post = new WP_Query($args);
if ( $result_post->have_posts() ) {
echo '<ul>';
while ( $result_post->have_posts() ) {
$result_post->the_post();
echo '<li>' . get_the_title() . '</li>';
echo '<li>' . the_meta() . '</li>';
echo '<li>' . get_post_meta(get_the_id(),"name",true) . '</li>';
}
echo '</ul>';
global$wpdb;
$args=array('post_type'=>'user');
$result\u post=新的WP\u查询($args);
如果($result\u post->have\u posts()){
回声“”;
而($result\u post->have\u posts()){
$result_post->the_post();
回显“- ”。获取标题();
回显“
- ”。the_meta()“
”;
回显“- ”。获取发布元数据(获取id(),“name”,true)。“
”;
}
回声“
”;
Do person left join skill,与团队合作。
global $wpdb;
$args = array('post_type' => 'user');
$result_post = new WP_Query($args);
if ( $result_post->have_posts() ) {
echo '<ul>';
while ( $result_post->have_posts() ) {
$result_post->the_post();
echo '<li>' . get_the_title() . '</li>';
echo '<li>' . the_meta() . '</li>';
echo '<li>' . get_post_meta(get_the_id(),"name",true) . '</li>';
}
echo '</ul>';