Home > Backend Development > PHP Tutorial > wordpress postmeta中的点和空格的具体含义

wordpress postmeta中的点和空格的具体含义

WBOY
Release: 2016-06-23 14:28:34
Original
1072 people have browsed it

本帖最后由 moliu 于 2014-01-27 20:59:20 编辑

在 wordpress 中,有下面的语句。我疑惑的是:
        SELECT      key3.post_id
FROM        $wpdb->postmeta key3
----key3 后面的点,postmeta后的空格,各代表什么意思?
<?php $meta_key1		= 'model';$meta_key2		= 'year';$meta_key3		= 'manufacturer';$meta_key3_value	= 'Ford';$postids=$wpdb->get_col( $wpdb->prepare( 	"	SELECT      key3.post_id	FROM        $wpdb->postmeta key3	INNER JOIN  $wpdb->postmeta key1 	            ON key1.post_id = key3.post_id	            AND key1.meta_key = %s 	INNER JOIN  $wpdb->postmeta key2	            ON key2.post_id = key3.post_id	            AND key2.meta_key = %s	WHERE       key3.meta_key = %s 	            AND key3.meta_value = %s	ORDER BY    key1.meta_value, key2.meta_value	",	$meta_key1, 	$meta_key2, 	$meta_key3, 	$meta_key3_value) ); ?>
Copy after login

回复讨论(解决方案)

  $wpdb->postmeta key3意思是: $wpdb->postmeta表命名为key3,对吗?类似的表达还有:
 $wpdb->postmeta as key3

对!
$wpdb->postmeta as key3
令 $wpdb->postmeta 所表示的表命令为别名(alias) key3
当省略 as 时就是
$wpdb->postmeta key3

key3.post_id
表示 key3 表的 post_id 列

悟!
困绕我 几乎一年多了、这个问题。表的列名,也有别名,曾明确的学到过。表本身的别名,我没有明确的学到过。
这次全弄通了。
谢谢前辈指点。

w3schools.com sql aliases
http://www.w3schools.com/sql/sql_alias.asp

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template