MySQL查询三个表(MySQL query for three tables)
我有三个人表,属性和属性的潜在价值。 我无法找出一个查询来显示所有人,每个人属性及其缺失/ null属性。
这是一个示例表......attributes +---------------------+ | attribute_name (col)| +---------------------+ | name | +---------------------+ | age | +---------------------+ | gender | +---------------------+ | email | +---------------------+ people +-----------+----------+ | person_id | value_id | +-----------+----------+ | 2 | 7 | +-----------+----------+ | 2 | 9 | +-----------+----------+ | 3 | 8 | +-----------+----------+ values +---------------+----------------+-------+ | value_id (pk) | attribute_name | value | +---------------+----------------+-------+ | 7 | age | 35 | +---------------+----------------+-------+ | 8 | age | 28 | +---------------+----------------+-------+ | 9 | gender | male | +---------------+----------------+-------+
我如何加入这三个表来显示这样的东西?+-----------+----------+-----------------+--------+ | person_id | value_id | attribute_name | value | +-----------+----------+-----------------+--------+ | 2 | 7 | age | 35 | +-----------+----------+-----------------+--------+ | 2 | 9 | gender | male | +-----------+----------+-----------------+--------+ | 2 | NULL | name | NULL | +-----------+----------+-----------------+--------+ | 2 | NULL | email | NULL | +-----------+----------+-----------------+--------+ | 3 | 8 | age | 28 | +-----------+----------+-----------------+--------+ | 3 | NULL | gender | NULL | +-----------+----------+-----------------+--------+ | 3 | NULL | name | NULL | +-----------+----------+-----------------+--------+ | 3 | NULL | email | NULL | +-----------+----------+-----------------+--------+
I have three tables with people, the attributes and potential value for the attributes. I can't figure out a query to display all the people, each persons attributes and their missing/null attributes.
Here's an example table...attributes +---------------------+ | attribute_name (col)| +---------------------+ | name | +---------------------+ | age | +---------------------+ | gender | +---------------------+ | email | +---------------------+ people +-----------+----------+ | person_id | value_id | +-----------+----------+ | 2 | 7 | +-----------+----------+ | 2 | 9 | +-----------+----------+ | 3 | 8 | +-----------+----------+ values +---------------+----------------+-------+ | value_id (pk) | attribute_name | value | +---------------+----------------+-------+ | 7 | age | 35 | +---------------+----------------+-------+ | 8 | age | 28 | +---------------+----------------+-------+ | 9 | gender | male | +---------------+----------------+-------+
How do I join the three tables to display something like this?+-----------+----------+-----------------+--------+ | person_id | value_id | attribute_name | value | +-----------+----------+-----------------+--------+ | 2 | 7 | age | 35 | +-----------+----------+-----------------+--------+ | 2 | 9 | gender | male | +-----------+----------+-----------------+--------+ | 2 | NULL | name | NULL | +-----------+----------+-----------------+--------+ | 2 | NULL | email | NULL | +-----------+----------+-----------------+--------+ | 3 | 8 | age | 28 | +-----------+----------+-----------------+--------+ | 3 | NULL | gender | NULL | +-----------+----------+-----------------+--------+ | 3 | NULL | name | NULL | +-----------+----------+-----------------+--------+ | 3 | NULL | email | NULL | +-----------+----------+-----------------+--------+
原文:https://stackoverflow.com/questions/14674949
最满意答案
谢谢,@martync! 将我的评论作为答案重新发布,因为它实际上已经回答了问题。
该文档明确指出“您不能在HTML文档中使用JavaScript来触发打印” ,并提供了如何使用Java API的示例。 Chrome for Android(至少是Beta)支持
window.print()
。Thanks, @martync! Reposting my comment as an answer, as it has turned out to actually answer the question.
The documentation explicitly says "You cannot use JavaScript in a HTML document to trigger printing", and provides an example of how to use the Java API. Chrome for Android (at least Beta) supports
window.print()
.
相关问答
更多-
需要webview的帮助(need help for webview)[2023-03-01]
最后我得到了错误的解决方案。 我在用着: btn.post(new Runnable() { @Override public void run() { btn.requestFocus(); btn.setVisibility(0); } } 之后,当我想要显示按钮时,我正在开始一个新线程 Finally I got the solution of the error. I'm using: btn.post(new Runnable() { ... -
首先,字符串中的' s '应替换为\' : body = body.replace("'", "\\'"); 然后应该删除所有换行符: body = body.replaceAll(System.getProperty("line.separator"), " "); 所有问题都解决了 first the 's in String should be replaced with \' : body = body.replace("'", "\\'"); then all newline char sh ...
-
您声明了文本,但没有使用它。 webview.loadUrl("javascript:(function() { " + "var text = 'HELLO';"+ "document.body.innerHTML = document.body.innerHTML.replace(/"+letter+"/g, ''+text+'');"+ ...
-
不要将UIWebView用于针对iOS 8及更高版本的新代码,而是使用WKWebView 。 Apple在UIWebView文档中有这样的说法: 在iOS 8及更高版本中运行的应用程序中,使用WKWebView类而不是使用UIWebView。 此外,如果渲染不应运行JavaScript的文件,请考虑将WKPreferences属性javaScriptEnabled设置为NO。 以下是使用WKWebView评估Javascript的WKWebView : self.webView.evaluateJavaSc ...
-
请在触发loadUrl-method之前设置您的webview设置: WebView view =(WebView)findViewById(R.id.webview); WebSettings settings = view.getSettings(); settings.setJavaScriptEnabled(true); view.loadUrl("file:///android_asset/first.html"); Aargh! Stupid mistake i ...
-
Android HTML WebView(Android HTML WebView)[2022-09-26]
来自assets文件夹 webview.loadUrl("file:///android_asset/file.html"); 从特定文件夹 webview.loadUrl("file:///data/data/com.example.example/files/file.html"); from assets folder webview.loadUrl("file:///android_asset/file.html"); from specific folder webview.loadUrl ... -
Android打印HTML文档(Android Print HTML Document)[2022-06-12]
Android应用程序的结构包含许多组件:活动,片段,服务,适配器,模型和控制器/业务类。 每个组件都extends了一个特定的android类。 例如,活动扩展了Activity类或AppCompatActivity类。 片段可以扩展Fragment类,服务扩展Service类,等等... 有一些方法只能用于活动,因为它们是Activity类方法(或方兴未艾)。 因此,如果您需要使用getActivity()方法,该方法可以被Fragment使用,但是您不在片段中,则需要以其他方式获取活动。 例如: pr ... -
谢谢,@martync! 将我的评论作为答案重新发布,因为它实际上已经回答了问题。 该文档明确指出“您不能在HTML文档中使用JavaScript来触发打印” ,并提供了如何使用Java API的示例。 Chrome for Android(至少是Beta)支持window.print() 。 Thanks, @martync! Reposting my comment as an answer, as it has turned out to actually answer the question. T ...
-
实际上有一种方法可以将View所有内容添加到Canvas 。 它是: view.draw(canvas); 来自Android Developer:查看 : public void draw (画布帆布) 在API级别1中添加手动将此视图(及其所有子级)渲染到给定的Canvas。 在调用此函数之前,视图必须已完成完整布局。 实现视图时,实现onDraw(android.graphics.Canvas)而不是重写此方法。 如果确实需要覆盖此方法,请调用超类版本。 参数 canvas要呈现视图的Canvas。 ...
-
打印WebView将作为Java 8的功能添加。 您可以下载将实现该功能的Java 8预发行版 。 Java 8将于明年3月发布。 功能跟踪器: RT-17666 Webview和HTMLEditor应支持打印其内容 附注 :在您发布的代码中,您将JavaFX和Swing代码混合在同一个线程上。 通常,您不应该这样做=> 有关详细信息,请参阅JavaFX Swing互操作性教程 。 Printing WebView will be added as a feature for Java 8. You can ...